4 Replies Latest reply on Sep 23, 2019 9:20 AM by bjoern-cusatum

    ARM not passing specified parameters to powershell script.


      So I wish to use ARM to run a powershell script when it creates the user.

      The user creation part all works successfully, however when it runs the powershell script this is what happens:


      I've configured it to run this script:






      Contents of the "ExchangeParam.ps1" script:

      $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://FQDNExchangeServer/PowerShell/ -Authentication KerberosImport-PSSession $Session

      $args[1] = $samaccountname

      Send-MailMessage -From 'SolarwindsARM@contoso.com' -To 'myworkemail@contoso.com' -Subject 'Test mail' -SmtpServer 'exchangesmtp.contoso.com' -Body "The parameter name is: $samaccountname and being passed through the script correctly."




      I create a user in ARM and ensure the checkbox is ticked to Start the external program/powershell script.


      The user I created was called: Test User

      samaccountname:     usetes


      When I go to look at the logs, the {samaccountname} parameter which is passed to the powershell script, is just being appended to the end of the powershell script.. as you can see below:


      Custom executable finished with output: [000] powershell.exe -inputformat none -File "C:\ProgramData\protected-networks.com\8MAN\scripts\analyze\ExchangeParam.ps1" usetes



      The user is created successfully and I receive the email:


      The parameter name is: and being passed through the script correctly.



      So the script isnt getting the parameter passed to it correctly... All ARM is doing is appending the {samaccountname} parameter to the end of the powershell command and thats it..


      Am I missing something here??? All the doco I can find online has the exact same info and all correct... I'm not sure what I'm doing incorrectly here????