Run PowerShell Script

Greetings,

i want to run powershell script after AD user account creation. i have added the component powershell script but dont know how to execute the script from there and pass parameter like -identity.

Can anyone help me here?

Regards,

Prasad

Parents
  • this is the script

    Dim theScript As New StringBuilder()
    theScript.AppendLine("$session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exsrv1/PowerShell -Authentication Kerberos")
    theScript.AppendLine("""")
    theScript.AppendLine("Import-PSSession $session -DisableNameChecking -AllowClobber")
    theScript.AppendLine("""")
    theScript.AppendLine("$identity = 'user1'")
    theScript.AppendLine("set-mailbox -identity $identity -CustomAttribute1 'IDMUPDATE'")
    Value = theScript.ToString()

    getting error - 

    The term 'set-mailbox' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct

    if i run this in PowerShell ISE it works fine.

    Regards,

    Prasad

     

  • This error usually means that you don't have the Exchange PowerShell module loaded. In your case, it may indicate that you failed to connect to your Exchange server.

    Maybe 1IM's service user is not the same you are using with PowerShell ISE? I would try to specify credentials in your connection: New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://exsrv1/PowerShell -Authentication Kerberos -Credential XXXX

  • Thanks for the reply. the issue is resolved. it was due to some wrong terminator.

Reply Children
No Data