Q. How can I run a PowerShell cmdlet against a remote computer?

If the cmdlet has a -computerName parameter, then just use that. Otherwise, you'll need to use remoting.

Don Jones

June 16, 2010

1 Min Read
swimmer in pool lane view from above

Q. How can I run a PowerShell cmdlet against a remote computer?

A. If the cmdlet has a -computerName parameter, then just use that. Otherwise, you'll need to use remoting, which must be enabled on the remote computer by running

 Enable-PSRemoting

on it. (PowerShell 2.0 must be installed on your computer and the remote computer.) Then, run

 Invoke-Command -scriptblock { #whatever } -computername remote-computer

on your computer. Substitute your desired cmdlet for #whatever and insert the proper computer name in place of remote-computer. You only have to enable remoting once. After doing so, you can invoke commands on the remote-enabled computer whenever you like. You'll usually need to have PowerShell running as Administrator, or you'll have to add the -credential parameter to Invoke-Command and specify Administrator credentials for the remote machine.

Do you have a Windows PowerShell question? Find more PowerShell FAQs, articles, and other resources at windowsitpro.com/go/DonJonesPowerShell.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like