Skip to page contentSkip to chat
ServiceNow support
    • Community
      Ask questions, give advice, and connect with fellow ServiceNow professionals.
      Developer
      Build, test, and deploy applications
      Documentation
      Find detailed information about ServiceNow products, apps, features, and releases.
      Impact
      Accelerate ROI and amplify your expertise.
      Learning
      Build skills with instructor-led and online training.
      Partner
      Grow your business with promotions, news, and marketing tools
      ServiceNow
      Learn about ServiceNow products & solutions.
      Store
      Download certified apps and integrations that complement ServiceNow.
      Support
      Manage your instances, access self-help, and get technical support.
Enable and Test PowerShell Remoting on a Windows Host - Support and Troubleshooting
  • >
  • Knowledge Base
  • >
  • Support and Troubleshooting (Knowledge Base)
  • >
  • Enable and Test PowerShell Remoting on a Windows Host
KB0813330

Enable and Test PowerShell Remoting on a Windows Host


122649 Views Last updated : Jun 26, 2025 public Copy Permalink English (Original)
  • English (Original)
  • Japanese
KB Summary by Now Assist

Issue

Windows discovery uses PowerShell remoting to automatically run scripts on target devices. The following steps verify that PowerShell remoting is enabled and working on each machine. 

If it is not working, you may see a common error such as: 

Failed to launch process powershell -ExecutionPolicy ByPass -NonInteractive -WindowStyle Hidden -command

Release

Madrid 3 and newer versions

Resolution

Enable PowerShell remoting

To make a remote connection on your server, do the following: 

  1. Open PowerShell, and select Run as administrator.
        1.    
        2.  
  2. In the PowerShell window, type the cmdlet, Enable-PSRemoting -Force.
  3. Select Enter.

 

This command starts the WinRM service, sets it to start automatically with your system, and creates a firewall rule that allows incoming connections. The -Force part of the cmdlet tells PowerShell to perform these actions without prompting you for each step.

Add a remote-connected host to <trust zone>

  1. Open PowerShell and select Run as administrator.
  2. In the PowerShell window, type Set-Item wsman:\localhost\client\trustedhosts *

The asterisk is a wildcard symbol for all hosts. To restrict servers that can connect, replace the asterisk with a comma-separated list of IP addresses or hostnames.

Restart the WinRM service

  1. In the PowerShell window, type the cmdlet, Restart-Service WinRM
  2. Select Enter.

Test the connection

  1. From the MID Server, run the following cmdlet into PowerShell: Test-WsMan <Target IP>
  2. Select Enter.

This command tests whether the WinRM service is running on the remote host.

  • If it completes successfully, information about the remote host WinRM service displays, indicating that WinRM is enabled and your <Target Host> can communicate.
  • If the command fails, an error message displays instead.

Run a single remote command on the remote system

Use the Invoke-Command cmdlet as follows: 

Invoke-Command -ComputerName COMPUTER -ScriptBlock { COMMAND } -credential USERNAME.
Example

The following command displays the contents of the C:\ directory on a remote host with the IP address and a username:

Invoke-Command -ComputerName <TargetIP> -ScriptBlock { Get-ChildItem C:\ } -credential domain\username

To run several cmdlets on the remote host

Instead of repeating the Invoke-Command cmdlet and the remote IP address, start a remote session instead. To do this:

  1. Type the cmdlet: Enter-PSSession -ComputerName <Target IP> -Credential Domain\USER
  2. Select Enter.

 

 

 

 

Related Links

PowerShell remoting for Discovery

MID Server PowerShell files


The world works with ServiceNow.

Sign in for more! There's more content available only to authenticated users Sign in for more!
Did this KB article help you?
Did this KB article help you?

How would you rate your Now Support digital experience?

*

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

Very unsatisfied

Unsatisfied

Neutral

Satisfied

Very satisfied

What can we improve? Please select all that apply.

What are we doing well? Please select all that apply.

Tell us more

*

Do you expect a response from this feedback?

  • Terms and conditions
  • Privacy statement
  • GDPR
  • Cookie policy
  • © 2025 ServiceNow. All rights reserved.