I have a problem, I have a script which:
PSSession
with admin account)I want to start process on server, so i'm connect with PSSession (No problem)
I do Invoke-Command :
# $pathProg path to my program
Invoke-Command -session $mySession -command {Start-Process $($args[0])} -ArgumentList $pathProg
But it does nothing (I verify with VNC)
I do Invoke-Command too :
# $pathProg path to my program
Invoke-Command -session $mySession -command {&$($args[0])} -ArgumentList $pathProg
It lauch the program (Good) but my script wait the end program (Not good)
Anyone have an idea ?
Thanks
You can try using WMI:
$command = "notepad.exe"
$process = [WMICLASS]"\\$CompName\ROOT\CIMV2:win32_process"
$result = $process.Create($command)
If you need passing credentials:
$cred = get-credential
$process = get-wmiobject -query "SELECT * FROM Meta_Class WHERE __Class = 'Win32_Process'" -namespace "root\cimv2" -computername $CompName -credential $cred
$results = $process.Create( "notepad.exe" )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With