- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 07:42 AM
So I am just testing a new custom PowerShell activity. This works fine and does exactly what I would expect in a test:
However, when I add this to a script file, I can't figure out how to pass my ${activityInput.groupName} variable to the $Server variable in the PowerShell script. Here is the script I added to the Midserver:
How do I pass my ${activityInput.groupName} into the Powershell script file?
I tried changing my Midserver script to this:
and then updating my Powershell custom activity to this:
But that also didn't work....
Any help here?
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:36 AM
For anyone trying to do this in the future, we found 2 different ways to do it...both easy:
Solution 1:
Point to the PS1 file and then pass the variable ($Server was the variable in our Example). In our example, we were just outputting a text file on the midserver so our target host was the midserver itself. I had to check "Use MID Service Account" because of creating the text file on itself when running.
Solution 2:
Go to MID Server -> Script Files and create a new Script there. Below is the screenshot of the script you would then point to in your custom Powershell activity. The custom Powershell activity "Script Type" would then become a "MID Server Script File" (then choose your script you created) and the "Server" variable in my example would now be "Servername" because of Servername being my variable in the below screenshot.
These are just examples of how to pass variables to a custom PS1 file or a Script File created within ServiceNow in the MID Server application.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 07:57 AM
Below should help you
https://community.servicenow.com/community?id=community_article&sys_id=6801f040dbfbdf00feb1a851ca9619f3
Regards,
Sachin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-17-2019 08:05 AM
That seems complicated...
Is there any benefit to using a MID Server Script file over a Customer PowerShell Command in my custom activity? I can do what I want in a Custom PowerShell Command, but was just trying to test out using a MID Server Script file.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-18-2019 10:36 AM
For anyone trying to do this in the future, we found 2 different ways to do it...both easy:
Solution 1:
Point to the PS1 file and then pass the variable ($Server was the variable in our Example). In our example, we were just outputting a text file on the midserver so our target host was the midserver itself. I had to check "Use MID Service Account" because of creating the text file on itself when running.
Solution 2:
Go to MID Server -> Script Files and create a new Script there. Below is the screenshot of the script you would then point to in your custom Powershell activity. The custom Powershell activity "Script Type" would then become a "MID Server Script File" (then choose your script you created) and the "Server" variable in my example would now be "Servername" because of Servername being my variable in the below screenshot.
These are just examples of how to pass variables to a custom PS1 file or a Script File created within ServiceNow in the MID Server application.
Please mark this response as correct and/or helpful if it assisted you with your question.
Steven

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2020 11:09 AM
can you please share the PowerShell Script?
Thanks,
Imane