Pooja Chugwani
ServiceNow Employee
ServiceNow Employee

Perform the following steps to execute the Powershell script on a remote machine or on a MID server.

  1.  Install the "Integration Hub" plugin.
  2.  Add credential for Remote windows machine. Make sure to add '.\' before username for Windows eg- .\administrator.

If you won't add .\  then your test credential will pass but PowerShell script execution will give the following error.


Error      Authentication failure with the user administrator
Error      Failed while executing commandScript452652376890409220.PS1 (Access denied)
Error      Authentication failure with the user administrator.

3. Navigate to Flow Designer from the left menu and Click New. Select Action.

4.Provide any name ("Powershell -test" ) in the Action Name field and submit.

5. Click "Create Input" to create input Parameter. Update the Lable as hostname. Provide remote machine's IP address or mid server's IP address to hostname while testing action.

6.Click '+' and select the PowerShell option from the popup menu.

find_real_file.png

 

find_real_file.png

7.Select "Use Credential Alias" in the connection dropdown field. Click on + next to the credential alias field to create a new connection.

find_real_file.png

8.Provide any name in the Name field. Select the correct Windows credential. Select alias if already created or create a new credential alias of type "Connection and Credential".Provide Remote Machine's IP address or MID server IP address in the Host field. Select "Use Mid Server" and select a specific one that can access the Remote machine.

find_real_file.png

8.Select Remoting type as "Explicit Remoting" to execute Powershell script on a remote machine and "Run on a MID Server or have your script establish a remote session" to execute PowerShell script on MID server.

9. Select script type as "Inline Script".Provide any simple Powershell command in the script window like Get-Process.

10. Save and Test the action.

 

Let me know if you have any questions in the comments. 

Comments
GokulkumarV5812
Tera Explorer

Hi @Pooja Chugwani ,

 

Thanks for the article. One suggestion from me is that, can you mention the plugin name 'ServiceNow IntegrationHub Action Step - PowerShell' explicitly. And this has  to be requested through catalog.

 

It took some time for me to figure this out, as this post mentioned Integration Hub plugin generically.

 

Cheers,

Gokulkumar

Version history
Last update:
‎03-08-2021 12:28 PM
Updated by: