header image

Scripting Games Commentary: V – Remoting

Posted by: | April 28, 2011 | 2 Comments |

In PowerShell we have a number of ways to perform actions on remote machines. Many of the scenarios in the Scripting Games introduced the need to perform some action on a remote machine.

Many of the solutions involved creating sessions, using invoke-command and then tearing down the sessions.


The problem is to get a few bits of information off the remote machine. Do you know PowerShell is installed on the remote machine? It isn’t installed on all the machines in my environment.

There is a quick remoting technique for situations like this. We don’t want to, or can’t, establish a remote session. Look at the cmdlets with a –ComputeName parameter. These can work with remote machines without needing to configure PowerShell remoting. Which cmdlets? Glad you asked.

PS> Get-Help * -Parameter Computer* | format-wide

Get-WinEvent                                                Get-Counter
Test-WSMan                                                  Invoke-WSManAction
Connect-WSMan                                               Disconnect-WSMan
Get-WSManInstance                                           Set-WSManInstance
Remove-WSManInstance                                        New-WSManInstance
Invoke-Command                                              New-PSSession
Get-PSSession                                               Remove-PSSession
Receive-Job                                                 Enter-PSSession
Get-EventLog                                                Clear-EventLog
Write-EventLog                                              Limit-EventLog
Show-EventLog                                               New-EventLog
Remove-EventLog                                             Get-WmiObject
Invoke-WmiMethod                                            Get-Process
Remove-WmiObject                                            Register-WmiEvent
Get-Service                                                 Set-Service
Set-WmiInstance                                             Get-HotFix
Test-Connection                                             Restart-Computer

All of these cmdlets can access remote machines directly. Use them rather than remoting for the simple jobs they were designed for.

under: PowerShellV2, Scripting Games


  1. By: Barry Morrison on April 28, 2011 at 1:48 pm      

    Get-Process does allow for a -ComputerName parameter, but Get-Process -ComputerName -FileVersionInfo is not supported on remote machines (this was frustrating in the Games).

  2. By: Jacques Willemen on April 28, 2011 at 3:34 pm      

    Hey Richard,
    You are right!
    But of the 35 cmdlets you list, 12 (one out of three) are WSMan of PSSession cmdlets.
    And still….you’re right.
    Thx for your blog, modules, books, ideas!