Tip: Work Remotely with Windows PowerShell without using Remoting or WinRM

Follow Our Daily Tips

Twitter | Blog | RSS | Facebook

Some cmdlets have a –ComputerName parameter that lets you work with a remote computer without using Windows PowerShell remoting. This means you can use the cmdlet on any computer that is running Windows PowerShell, even if the computer is not configured for Windows PowerShell remoting. These cmdlets include the following:

  • Get-WinEvent
  • Get-Counter
  • Get-EventLog
  • Clear-EventLog
  • Write-EventLog
  • Limit-EventLog
  • Show-EventLog
  • New-EventLog
  • Remove-EventLog
  • Get-WmiObject
  • Get-Process
  • Get-Service
  • Set-Service
  • Get-HotFix
  • Restart-Computer
  • Stop-Computer
  • Add-Computer
  • Remove-Computer
  • Rename-Computer
  • Reset-ComputerMachinePassword

Because these cmdlets don’t use remoting, you can run any of these cmdlets on a remote computer in a domain simply by specifying the name of one or more remote computers in the –ComputerName parameter. However, Windows policies and configuration settings must allow remote connections, and you must still have the appropriate credentials.

The following command runs Get-WinEvent on PrintServer35 and FileServer17:
get-winevent –computername printserver35, fileserver17

When you use ComputerName, these cmdlets return objects that include the name of the computer that generated the data. The remote computer name is stored in the MachineName property. Typically, the MachineName property is not displayed by default. The following example shows how you can use the Format-Table cmdlet to add the MachineName property to the output:
$procs = {get-process -computername Server56, Server42, Server27 |
sort-object -property Name}
&$procs | format-table Name, Handles, WS, CPU, MachineName –auto

You can get a complete list of all cmdlets with a –ComputerName parameter by typing the following command: get-help * -parameter ComputerName. To determine whether the –ComputerName parameter of a particular cmdlet requires Windows PowerShell remoting, display the parameter description by typing get-help CmdletName -parameter ComputerName, where CmdletName is the actual name of the cmdlet, such as:
get-help Reset-ComputerMachinePassword -parameter ComputerName

Type the NetBIOS name, an IP address, or a fully qualifi ed domain name of a remote computer. To specify the local computer, type the computer name, a dot (.), or localhost. This parameter does not rely on Windows PowerShell remoting. You can use the –ComputerName parameter even if your computer is not configured to run remote commands.

From the Microsoft Press book Windows PowerShell 2.0 Administrator’s Pocket Consultant by William R. Stanek.

Looking for More Tips?

For more tips on using Microsoft products and technologies, visit the TechNet Magazine Tips library.