Cercando di chiamare uno script PowerShell che prende in un argomento, viene eseguito ogni lavoro in background, e mi mostra l'output dettagliato.
problema che sto funzionando in
Lo script sembra funzionare, ma voglio verificare questo di sicuro in streaming i risultati dei processi in background mentre sono in esecuzione.
Codice
###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
Quello che attualmente sto vedendo:
Id Name State HasMoreData Location Command
-- ---- ----- ----------- -------- -------
23 Job23 Running True localhost #patch server ...
25 Job25 Running True localhost #patch server ...
Quello che voglio vedere:
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
Voglio essere in grado di vedere l'output o negozio che da qualche parte in modo da poter rimando per essere sicuri che lo script ha funzionato e vedere quali server riavviati, ecc
Conclusione:
In passato, ho ha eseguito lo script ed è passato attraverso l'aggiornamento dei server uno alla volta e mi ha dato l'output che volevo, ma quando ho iniziato a fare più server - questa attività ha richiesto troppo tempo, motivo per cui sto cercando di utilizzare i processi in background con "Start- Lavoro".
Qualcuno può aiutarmi a capirlo, per favore?
Roman, grazie per la risposta. Questo è il più vicino che potrei ottenere per avere l'output esattamente come lo volevo. Ottengo alcuni errori di output aggiuntivi, che risolverò, ma questo metodo non solo esegue il mio script, ma mi mostra l'output che desidero. Grazie. –
@ talbert.houle, sono felice che tu abbia trovato utile questo strumento. Se hai idee su come renderlo migliore, puoi inviarlo sul sito del progetto. –