Bryan Spillman
2014-08-13 22:55:38 UTC
So this is the code that is giving me fits...
The thing that concerns me is I am returning the PID of the cmd.exe process and not the cscript.exe process when launching this.
I have a tool I have built that basically will multi thread any script without you needing to modify it. Just put in the correct directory and answer 5 prompts.
Thread Limit is up to you!
$cmd = "cmd /c CD " + $file.Directory + " & cscript.exe //nologo " + $file.FullName
[wmiclass]$wmi="\\$server\root\cimv2:win32_process"
if (!$wmi) {
Write-Host "WMI Failed Locally..." -ForegroundColor RED
}
$remote = $wmi.Create($cmd)
if ($remote.returnvalue -eq 0) {
Write-Host "Success:" $x $tab $remote.processid -ForegroundColor GREEN
$PIDS += $remote.processid
$x++ #scriptlaunched
}
else {
Write-Host $cmd $tab "Failure:" $tab $remote.ReturnValue -ForegroundColor RED
}
I have same option built in for threading powershell scripts.
The thing that concerns me is I am returning the PID of the cmd.exe process and not the cscript.exe process when launching this.
I have a tool I have built that basically will multi thread any script without you needing to modify it. Just put in the correct directory and answer 5 prompts.
Thread Limit is up to you!
$cmd = "cmd /c CD " + $file.Directory + " & cscript.exe //nologo " + $file.FullName
[wmiclass]$wmi="\\$server\root\cimv2:win32_process"
if (!$wmi) {
Write-Host "WMI Failed Locally..." -ForegroundColor RED
}
$remote = $wmi.Create($cmd)
if ($remote.returnvalue -eq 0) {
Write-Host "Success:" $x $tab $remote.processid -ForegroundColor GREEN
$PIDS += $remote.processid
$x++ #scriptlaunched
}
else {
Write-Host $cmd $tab "Failure:" $tab $remote.ReturnValue -ForegroundColor RED
}
I have same option built in for threading powershell scripts.