Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Windows PowerShell v2 includes built-in remoting for many commands, using the -computername parameter.
( for a quick list of commands that support this parameter, but don't require full session support try this:
PS> get-command | where { $_.parameters.keys -contains "ComputerName" -and $_.parameters.keys -notcontains "Session"}
)
One of the advantages of this built-in remoting is that you don't need to have full WS-Man remoting enabled to use these commands, unlike using the PSSession commands. This means you can easily find out if the DNS Server service is running on a remote computer with:
PS> Get-Service DNS -computername <computername>
You can also use built-in remoting for things like Get-Process, but there's a catch. Get-Process requires that the RemoteRegistry service be running. So the following is expected:
PS> Get-Service RemoteRegistry -Computername Charlie-PC
Status Name DisplayName
------ ---- -----------
Stopped RemoteRegistry Remote Registry
PS> Get-Process PowerShell -Computername Charlie-PC
Get-Process : Couldn't connect to remote machine.
At line:1 char:12
- Get-Process <<<< PowerShell -Computername Charlie-PC
+ CategoryInfo : NotSpecified: (:) [Get-Process], InvalidOperationException
+ FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.Commands.GetProcessCommand
This is true even though I do have WS-Man functionality enabled on Charlie-PC, allowing me to do the following:
PS> $CharliePC = New-PSSession Charlie-PC
PS> Invoke-Command -Session $CharliePC -scriptblock { ps PowerShell }
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName PSComputerName
------- ------ ----- ----- ----- ------ -- ----------- --------------
768 31 54916 56072 600 1.51 1084 powershell charlie-pc
506 29 159344 149904 586 7.47 3612 powershell charlie-pc
536 34 47924 55068 588 1.84 5144 powershell charlie-pc