Windows PowerShell remoting depends on the Windows Remote Management (WinRM) service. The service must be running to support remote commands.

On Windows Server 2003, Windows Server 2008, and Windows Server 2008 R2, the startup type of the Windows Remote Management (WinRM) service is Automatic. However, by default, on Windows XP, Windows Vista, and Windows 7, the WinRM service is disabled and you have to change the startup type to Automatic.

If you try to establish a remote connection and the WinRM service is not started, Windows PowerShell displays the following error message.

  Copy Code
ERROR:ACCESS IS DENIED

To view the startup type of the WinRM service

  • To view the startup type of the WinRM service, use the Get-WmiObject cmdlet with the Win32_Service object. The object that the Get-Service cmdlet returns does not include the startup type of the service.

    The following command gets the startup type of the WinRM service on the Server01 and Server02 computers. The startup type appears in the value of the StartMode property of the object that Get-WmiObject returns.

      Copy Code
    C:\PS> get-wmiobject win32_service -filter "name='WinRM'" -computername Server01, Server02
    
    ExitCode  : 0
    Name	: WinRM
    ProcessId : 848
    StartMode : Auto
    State	 : Running
    Status	: OK
    
    ExitCode  : 0
    Name	: WinRM
    ProcessId : 1308
    StartMode : Auto
    State	 : Running
    Status	: OK
    

To set the startup type of the WinRM service

  • To set the startup type of the WinRM service on a remote computer, use the Set-Service cmdlet. The following command sets the startup type of the computers that are listed in the value of the ComputerName parameter.

      Copy Code
    set-service WinRM -computername computer-names -startuptype Automatic
    

To set the startup type of a large number of computers

  1. Create a .txt or .csv file of the computer names.

  2. Use the Get-Content or Import-CSV cmdlets to get the computer names from the file, and then assign them to a variable. For example, the following command gets the computer names from the Servers.txt file and saves them in the $servers variable.

      Copy Code
    $servers = get-content servers.txt
    
  3. Use the Set-Service cmdlet to set the startup type of the WinRM service on all of the computers in the $servers variable.

      Copy Code
    set-service WinRM -computername $servers -startuptype Automatic
    

See Also