Enable WinRM for Remote Computer with Windows PowerShell

Q

How to enable WinRM on the remote computer? I want to access it from my local computer with Windows PowerShell sessions.

✍: FYIcenter.com

A

To support Windows PowerShell sessions, you need to perform the following tasks on the remote computer:

  • Starting or restarting (if already started) the WinRM service
  • Setting the WinRM service type to auto start
  • Creating a listener to accept requests on any IP address
  • Enabling firewall exception for WS-Management traffic (for http only).

You can finish these tasks on the remote computer with the "Enable-PSRemoting" PowerShell cmdlet as described below:

1. Login to the remote computer and start a PowerShell window as Administrator by right-clicking the PowerShell shortcut and selecting "Run as Administrator"

2. Run the "Enable-PSRemoting" cmdlet and enter "Y" at each prompt:

PS C:\Windows\system32> Enable-PSRemoting

WinRM Quick Configuration
Running command "Set-WSManQuickConfig" to enable this machine for remote management through WinRM service.
 This includes:
    1. Starting or restarting (if already started) the WinRM service
    2. Setting the WinRM service type to auto start
    3. Creating a listener to accept requests on any IP address
    4. Enabling firewall exception for WS-Management traffic (for http only).

Do you want to continue?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):
WinRM has been updated to receive requests.
WinRM service type changed successfully.

WinRM has been updated for remote management.
Created a WinRM listener on HTTP://* to accept WS-Man requests to any IP on this machine.
WinRM firewall exception enabled.

Confirm
Are you sure you want to perform this action?
Performing operation "Registering session configuration" on Target "Session configuration "Microsoft.PowerShell3
not found. Running command "Register-PSSessionConfiguration Microsoft.PowerShell32 -processorarchitecture x86 -f
to create "Microsoft.PowerShell32" session configuration. This will restart WinRM service.".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):

3. Test the WinRM configuration with more PowerShell cmdlets:

PS C:\Windows\system32> test-wsman localhost
wsmid           : http://schemas.dmtf.org/wbem/wsman/identity/1/wsmanidentity.xsd
ProtocolVersion : http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor   : Microsoft Corporation
ProductVersion  : OS: 0.0.0 SP: 0.0 Stack: 2.0

PS C:\Windows\system32> invoke-command localhost {query user}
 USERNAME              SESSIONNAME        ID  STATE   IDLE TIME  
 fyicenter             rdp-tcp#0           2  Active          .  

The remote computer is ready for you local computer to access now.

 

"Enter-PSSession" Cmdlet in Windows PowerShell

"New-PSSession" Cmdlet Error in Windows PowerShell

Managing Remote Computer with Windows PowerShell

⇑⇑ Windows PowerShell Tutorials

2016-10-15, 3738🔥, 0💬