Remotely Launching Processes

Unfortunately, the Start-Process cmdlet has no -ComputerName parameter so you cannot use it to launch processes on remote machines.

Use WMI instead! This line will run calc.exe on your local machine:

PS> (Invoke-WmiMethod Win32_Process Create calc.exe).ReturnValue -eq 0
True

And this slight adaption will run calc.exe on a computer named "storage1" with Administrator credentials (adjust machine name and user name to your needs):

PS> (Invoke-WmiMethod Win32_Process Create calc.exe -ComputerName storage1
-Credential Administrator).ReturnValue -eq 0 True

Note that calc.exe will run but is not visible to anyone. So in real life, you'd use this technique to launch command line tools or applications that are designed to run unattended.

Twitter This Tip! ReTweet this Tip!


Posted Feb 07 2012, 06:00 AM by ps1
Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.