$Username = "user"
$Password = "Password"
$servers = get-content "c:\temp\servers.txt"
$sb = {c:\temp\PsExec.exe -h \\$server -u $Username -p $password cmd.exe /c "echo .
| Powershell.exe -executionpolicy bypass -file c:\script.ps1" > "$env:userprofile\Desktop\output.txt"}
foreach($server in $servers)
{
start-job -ScriptBlock $sb
}
this code works fine if i remove start-job, but executes one after the other, which takes lot of time.
I cannot use PSsession or invoke-command, since it is restricted in our environment.
This code never exits. It stops at this position:
+ CategoryInfo : NotSpecified: (:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
PsExec v1.98 - Execute processes remotely
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com