Start-Process on Remote Computer

Jun 20, 2007 at 5:17 PM
I am searching for a way to start a process on another computer, specifically a server. Is there a way to do it, I see that start-process does not contain a parameter for computer.
Coordinator
Jun 20, 2007 at 6:51 PM
Start-Process is a cmdlet wrapper around the .NET Process.Start method. It doesn't support this functionality. You might want to check out PSExec which is part of the Sysinternals suite and not actually a PowerShell cmdlet.

http://www.microsoft.com/technet/sysinternals/utilities/psexec.mspx
Jun 20, 2007 at 8:38 PM
Edited Jun 20, 2007 at 8:39 PM
Thanks for the reply.
I am actually trying to follow something I found while searching:
http://preetsangha.spaces.live.com/blog/cns!46FC6E00B8BE200F!117

My goal is to deploy a windows service remotely through an automated nany script.
Jun 20, 2007 at 9:27 PM
Well I found the answer.
This is my ps1 file:

function global:new-process()
{
param (string$computer, string$commandline=$(throw "Command line required."))

# Win32_Process. Create-Method Template Script"
# Created by PowerShell WmiExplorer
# /\/\o\/\/ 2006
# www.ThePowerShellGuy.com
#
# Fill InParams values before Executing
# InParams that are Remarked (#) are Optional

$Class = "Win32_Process"
$Method = "Create"
$LaunchArgs = $commandline,$null,$null,0

$MC = WmiClass"\\$Computer\ROOT\CIMV2:$Class"

"Calling Win32_Process."
$R = $mc.PSBase.InvokeMethod($Method, $LaunchArgs)
"Result :"
$R | Format-list
}

Call that with a computer name and command to execute and your good to go.
Coordinator
Jun 21, 2007 at 3:02 AM
Yep. WMI is a good way to go if you want to perform the operation on a remote computer.
Developer
Jun 21, 2007 at 6:20 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.