September 8th, 2013

PowerTip: Use PowerShell to Run a Command on a Remote Server

Doctor Scripto
Scripter

Summary: Learn how to use Windows PowerShell to run a command on a remote server.

Hey, Scripting Guy! Question How can I run a command on a remote server by using Windows PowerShell Remoting?

Hey, Scripting Guy! Answer Use the Invoke-Command cmdlet, specify the computer name, and place the command in a script block:

Invoke-Command -ComputerName server1 -ScriptBlock {hostname}

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

0 comments

Discussion are closed.