How to pass arguments from ServiceNow payload to powershell script via windows scheduled task?
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-16-2024 07:23 AM
I have a scheduled task that is running a powershell script. I need to pass some arguments to it from ServiceNow. You see below that arg0 and arg1 are in the payload. I need to set these to $UserName and $ComputerName in the powershell script. The script is running but these are not getting set. When I log, it just sets them to $arg0 and $arg1 as strings. Can anyone help?
Payload sent:
Trying to set the arguments in the task:
the full thing is: -ExecutionPolicy Bypass -File "C:\Test\aTest.ps1" -ComputerName $(arg0) -UserName $(arg1)
The powershell script runs but doesn't set the variables in the script. Any ideas?
0 REPLIES 0