Windows 7 PowerShell Remote Management

Windows 7 includes Windows PowerShell V2 which supports remote management of computers. Before using Windows PowerShell to manage a remote computer you need to configure the WinRM (Windows Remote Management) service on the remote computer. To manage a remote Windows 7 computer from Windows Vista or earlier versions of Windows you need to update Windows PowerShell to V2 or later. The syntax of remote Windows PowerShell is as follows:

icm hostname {powershell-command}

In this exercise we will see how to configure two Windows 7 computers, where one will be managed remotely using Windows PowerShell and WinRS. Make sure that you have network connectivity between the two computers:

  1. Log on to the first computer, namely the target computer and open an elevated command prompt.
  2. Type in the command WinRM Quickconfig and when prompted press the Y key and press Enter twice. WinRM will fail if the network connection type is set to Public. Also, in a non-AD domain environment you need to create a user account with same username and password on both computers and use this account to logon and perform tasks.
  3. Log off the target computer but do not turn it off.

  1. Log on to the second computer, namely the source or admin computer.
  2. From an elevated command prompt type in WinRM quickconfig, press Enter, then the Y key and finally Enter twice.
  3. Type in the command winrm set winrm/config/client @{TrustedHosts=”remote-computer-name”} and press Enter.

  1. Test your local connection by typing whoami – you should get the local computer\username.
  2. Now, execute the command winrs -r:Remote-computer-name whoami – you should get the remote computer name\username
  3. You can perform another test using ipconfig and winrs -r:Remote-computer-name ipconfig and compare the results.
  4. Enter the command PowerShell and press Enter – This starts Windows PowerShell.
  5. Type in Get-Process | Sort-Object -Property CPU -Descending | Select -First 10 and press Enter – you should get the local top 10 processes.
  6. Type in icm Remote-computer-name {Get-Process | Sort-Object -Property CPU -Descending | Select -First 10} and press Enter – you should get the remote computer top 10 processes.

Remember, that you need to run the command WinRM Quickconfig from an elevated command prompt on a remote computer that you want to manage remotely using either WinRS or Windows PowerShell. Briefly, WinRM Quickconfig configures the Windows Remote Management service and firewall rules, and enables the WinRM listener.

Finally, to run command-line tools on a remote computer such as, remote ipconfig, etc. use the winrs -r:hostname command while to use Windows PowerShell V2 commands use icm hostname command from the PowerShell command prompt.