none
small number of postprocessing errors in regard running powershell script from workflow RRS feed

  • Question

  • In my event viewer i get this message:

    WAL (2.17.0721.0): 01/23/2018 20:54:32.5349: RunPowerShellScript : RunScript: Exception in 'RunPowerShellScript : RunScript'. Details: System.NullReferenceException: Object reference not set to an instance of an object.

       at MicrosoftServices.IdentityManagement.WorkflowActivityLibrary.Activities.RunPowerShellScript.RunScript(String script, IEnumerable scriptArguments, Dictionary`2 scriptParameters).

     on the portal directly only getting that an internal error occured. I run 2 powershell scripts  (first one logs into file at the end and so i know that it runs smoothly and then i get this error. It only happens to a small subset of users most of them new users. I'm pretty stumped by this has anyone got an idea?

    Tuesday, January 23, 2018 8:29 PM

Answers

  • Without seeing what you are passing to the script, my guess is the property does not existing for this small set of users and somewhere null check is not done before referencing it and that is causing the NullReferenceException.
    • Marked as answer by Paddydrum Tuesday, April 17, 2018 12:33 PM
    Wednesday, January 24, 2018 3:13 PM
    Owner

All replies

  • Without seeing what you are passing to the script, my guess is the property does not existing for this small set of users and somewhere null check is not done before referencing it and that is causing the NullReferenceException.
    • Marked as answer by Paddydrum Tuesday, April 17, 2018 12:33 PM
    Wednesday, January 24, 2018 3:13 PM
    Owner
  • Hi Nilesh after doing a number of checks via tracing I can confirm that all variables the script requires are passed to it with a real value. It's been puzzling me for 2 weeks now
    Tuesday, February 6, 2018 12:25 PM
  • Would be helpful if you can post the configuration / screenshot of the activity.
    Tuesday, February 6, 2018 12:51 PM
    Owner
  • I have the same or a very similar issue.

    We try to clear some AD Attributes after deleting a Mailbox. i was able to reduce the problem to the following part of the code:

    $objuser = New-Object System.DirectoryServices.DirectoryEntry("LDAP://$dn", $username,$password)
        $objUser.PutEx(1, 'msExchMailboxGuid', 0)
        $objUser.PutEx(1, 'msexchhomeservername', 0)
        $objUser.PutEx(1, 'legacyexchangedn', 0)
        $objUser.PutEx(1, 'mail', 0)
        $objUser.PutEx(1, 'mailnickname', 0)
        $objUser.PutEx(1, 'msexchmailboxsecuritydescriptor', 0)
        $objUser.PutEx(1, 'msexchpoliciesincluded', 0)
        $objUser.PutEx(1, 'msexchrecipientdisplaytype', 0)
        $objUser.PutEx(1, 'msexchrecipienttypedetails', 0)
        $objUser.PutEx(1, 'msexchumdtmfmap', 0)
        $objUser.PutEx(1, 'msexchuseraccountcontrol', 0)
        $objUser.PutEx(1, 'msexchversion', 0)
        $objUser.CommitChanges() | Out-Null

    I can run the code manually without getting an exception.

    Setting the logLevel for MIMWAL from Warning to Verbose does not provide additional Events.

    I do log all the Parameters passed to the script. none of them are missing.



    • Edited by MMuellerM Thursday, August 30, 2018 2:59 PM
    Thursday, August 30, 2018 2:56 PM
  • We were able to resolve our issue.

    $objUser.PutEx() actually return some stuff that gets carried over to MIMWAL.

    use

    $objUser.PutEx() | out-null

    to resolve the issue. 

    @paddydrum: maybe you too have some unexpected output from your script?

    • Edited by MMuellerM Friday, August 31, 2018 2:17 PM
    Friday, August 31, 2018 2:16 PM