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

  • Hi Prasad,

    If you have the module PAG installed, you could have a look at jobchain PAG_PAGAccesOrder_CheckExisting_AccessRequest. 
    You may pass parameters to the parameter Script with the following notation 

    Value = PAG_CheckAccessRequest($UID_PAGAccessOrder$, values("Appliance").ToString(), values("Thumbprint").ToString(), CBool(values("IgnoreSSLErrors")), CBool(values("ConnectPrimaryNode")), values("ClusterIPv4Addresses").ToString(), values("ClusterIPv6Addresses").ToString())

    Inside the $-values are column values and values("Name") are variables that are defined in the pre-script of the chain.

    I hope this helps you further,
    Tomi Kääriäinen

  • Hi Tomi, thanks for your reply.. i dont have PAG module installed. wanted to run exchange command creating user account.

  • 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.