Windows PowerShell can remotely manage a Windows computer by enabling a feature called PowerShell Remoting. This feature can be useful when there is no GUI-based tool is available.
A service called Windows Remote Management (WinRM) makes a Windows device capable of being managed remotely. You need to set the appropriate firewall rules on both sides of the network or hosts to make PowerShell remoting possible. When connected via PowerShell remoting, you can run cmdlets and scripts as if you are running those commands interactively on the local computer. However, the Windows Firewall exception for the WinRM listener will fail if any of the network cards are configured to have a public type. In this scenario, we are configuring WinRM for computers that have no public network cards (the firewall will refuse to create exceptions on public network cards). If you have any public network card, you must change the network card type to either private or domain or disable it completely.
Network Card Type To Private
To change the network card type to private,
it is very straightforward. Open network status by right click on the network icon from bottom right of the desktop then select Open Network & Internet settings (in this scenario, I used Windows 10)
From Network status windows, click on Change connection properties.
Select Private radio button
Use Windows PowerShell to Manage Remote Computers
Windows PowerShell remoting is disabled by default on Windows 10 operating system. You need to manually enable it to perform remoting. You can run the WinRm quickconfig command to enable Windows Remote Management service. The enable-PSremoting -force command enables Windows PowerShell remoting.
In this section, we will use various cmdlets to manage remote computers. I am using two Windows 10 machines (SPMonkey-Win10-01 and SPMonkey-Win10-02) as shown below:
Configuring The Workstation Machine: SPMonkey-Win10-01
Firstly, we need to update the WinRM service on the machine SPMonkey-Win10-01. From Start menu, search for ‘services’ or press windows key and R to run the Run command then enter “services.msc”.
From Services windows, look for “Windows Remote Management (WS-Management)” then right click and select Properties to open its properties windows.
Change Startup type to “Automatic” and click on Start button to start the service then click OK button to close the properties windows. Close the Services window.
After the Windows Remote Management (WS-Management) has been started and running, now it’s time to open Windows PowerShell by run as Administrator to run some cmdlets.
Note: In the User Account Control dialog box, click Yes.
At the command prompt, type winrm quickconfig command to enable WinRM and press Enter.
To confirm WinRM is enable type Enable-PSRemoting -Force command to enable PowerShell remoting and press Enter.
To configure the trusted hosts, type Set-Item wsman:\localhost\client\trustedhosts * command and press Enter.
Configuring the workstation machine SPMonkey-Win10-02
Open the Windows PowerShell by run as Administrator. At the command prompt, type winrm
quickconfig command to enable WinRM and press Enter.
Now we are done with both computers SPMonkey-Win10-01 and SPMonkey-Win10-02. It is time to go back to the first computer SPMonkey-Win10-01 and manage the second computer by using Windows PowerShell Remoting.
Administering Windows with PowerShell Remoting
From Windows PowerShell windows on the first computer SPMonkey-Win10-01, type Enter-PSSession -ComputerName 192.168.0.5 -Credential Administrator with 192.168.0.5 is the IP address of SPMonkey-Win10-02.
Enter the administrator password then hit OK button. You are now in remote session that means that remote connection with 192.168.0.5, which is SPMonkey-Win10-02, is established.