展望调用PowerShell脚本,它接受一个参数,在后台运行的每个作业,让我看到详细的输出运行在parralel和视点视频流效果多个作业。
问题我遇到
脚本似乎运行,但我想他们正在运行流媒体后台作业的结果来验证这一点是肯定的。
代码
###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
什么我目前看到:
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
23 Job23 Running True localhost #patch server ...
25 Job25 Running True localhost #patch server ...
我希望看到的:
Searching for approved updates ...
Update Found: Security Update for Windows Server 2003 (KB2807986)
Update Found: Windows Malicious Software Removal Tool - March 2013 (KB890830)
Download complete. Installing updates ...
The system must be rebooted to complete installation.
cscript exited on "myServer" with error code 3.
Reboot required...
Waiting for server to reboot (35)
Searching for approved updates ...
There are no updates to install.
cscript exited on "myServer" with error code 2.
Servername "myServer" is fully patched after 2 loops
我希望能够看到输出或存储在某个地方,所以我可以返回,以确保脚本运行,看看哪些服务器重启等
结论:
在过去,我运行脚本,并逐步更新服务器,并给我输出我想要的,但是当我开始做更多的服务器时 - 这项任务花费了很长时间,这就是为什么我试图使用“Start-工作”。
任何人都可以帮我解决这个问题吗?
罗马,谢谢你的回答。这是最接近我可以得到完全按照我想要的输出。我收到一些额外的输出错误,我将排除故障,但这种方法不仅运行我的脚本,而且显示我希望的输出。谢谢。 – 2013-03-26 12:50:31
@ talbert.houle,我很高兴你觉得这个工具很有用。如果您有关于如何使其更好的想法,欢迎您在项目现场提交。 – 2013-03-26 13:54:33