I'm testing some ideas here with the Scripting driver, PowerShell, and
our Office365 migration project. Cutting this down to only the relevant
pieces, what I'm trying to do is catch and correctly (status) report
errors from the PowerShell script calls out to the O365 commandlets back
to the IDM policy that called the script in the first place. It looks
like my attempt to catch the error is not working, though.

Level 3 trace:

Code:
[12/11/14 15:13:11.333]:O365 Migration ST:
<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product edition="Advanced" version="4.0.2.1">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<query class-name="Contact" dest-dn="EBlues" event-id="0"
scope="entry">
<read-attr attr-name="LegacyExchangeDN"/>
</query>
</input>
</nds>
[12/11/14 15:13:11.333]:O365 Migration ST:            Remote Interface
Driver: Sending...
[12/11/14 15:13:11.333]:O365 Migration ST:
<nds dtdversion="4.0" ndsversion="8.x">
<source>
<product edition="Advanced" version="4.0.2.1">DirXML</product>
<contact>Novell, Inc.</contact>
</source>
<input>
<query class-name="Contact" dest-dn="EBlues" event-id="0"
scope="entry">
<read-attr attr-name="LegacyExchangeDN"/>
</query>
</input>
</nds>
[12/11/14 15:13:11.333]:O365 Migration ST:            Remote Interface
Driver: Document sent.
[12/11/14 15:13:41.444]:O365 Migration :Remote Interface Driver: Received.
[12/11/14 15:13:41.444]:O365 Migration :
<nds dtdversion="1.1" ndsversion="8.6">
<source>
<product build="Mar 15 2011 11:29:46" version="4.0.1"/>
<contact/>
</source>
<output>
<status event-id="0" level="error">Error executing script command for
object [unknown] (code 1). Event discarded.</status>
</output>
</nds>
[12/11/14 15:13:41.444]:O365 Migration :Remote Interface Driver: Received
document for subscriber channel
[12/11/14 15:13:41.444]:O365 Migration :Remote Interface Driver: Waiting
for receive...
[12/11/14 15:13:41.444]:O365 Migration ST:
SubscriptionShim.execute() returned:
[12/11/14 15:13:41.444]:O365 Migration ST:
<nds dtdversion="1.1" ndsversion="8.6">
<source>
<product build="Mar 15 2011 11:29:46" version="4.0.1"/>
<contact/>
</source>
<output>
<status event-id="0" level="error">Error executing script command for
object [unknown] (code 1). Event discarded.</status>
</output>
</nds>
It's that "error" status that I'm trying to return with correct
information. Here's the PowerShell script:

Code:
function idm_query
{
$CLASS = IDM_GetEventValue("CLASS_NAME")
$IDENTITY =  IDM_GetEventValue("DEST_DN")

# PowerShell / Office365 Session initialization goes here

if ($CLASS -like "Contact")
{
$LEDN=get-mailcontact -identity $IDENTITY | select -Expand
legacyexchangedn

if ($LASTEXITCODE -eq 0)
{
IDM_SetCommand "INSTANCE"
if ($LEDN -like "")
{

IDM_StatusSuccess "Query succeeded: No contact found."
}
else
{
IDM_WriteValue "CLASS_NAME" $CLASS
IDM_WriteValue "ATTR_LegacyExchangeDN" $LEDN
IDM_StatusSuccess "Query succeeded"
}
}
else
{
IDM_StatusError "Query failed with error code $LASTEXITCODE"
}
}
else
{
IDM_StatusError "Query for unhandled object class"
}

# PowerShell / Office365 Session teardown goes here

}
I know that the Mail Contact I'm searching for here doesn't exist. So the
get-mailcontact() commandlet should be returning an error, which it does.
Yet the status message I'm returning isn't what I'm then seeing in the
level 3 trace from the event. Shouldn't it be?


--
--------------------------------------------------------------------------
David Gersic dgersic_@_niu.edu
Knowledge Partner http://forums.netiq.com

Please post questions in the forums. No support provided via email.
If you find this post helpful, please click on the star below.