概观
想要调用带有参数的Powershell脚本,在后台运行每个作业,并向我显示详细输出.
我遇到的问题
该脚本似乎正在运行,但我希望通过在后台作业运行时流式传输结果来确认这一点.
码
###StartServerUpdates.ps1 Script###
#get list of servers to update from text file and store in array
$servers=get-content c:\serverstoupdate.txt
#run all jobs, using multi-threading, in background
ForEach($server in $servers){
Start-Job -FilePath c:\cefcu_it\psscripts\PSPatch.ps1 -ArgumentList $server
}
#Wait for all jobs
Get-Job | Wait-Job
#Get all job results
Get-Job | Receive-Job
Run Code Online (Sandbox Code Playgroud)
我目前看到的是:
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
23 Job23 Running True localhost #patch server ...
25 Job25 Running True localhost #patch server …Run Code Online (Sandbox Code Playgroud)