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

     

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

     

Children