I have a script that i have been Runing on a list of Servers that i add a line to my script
ProcessVM "ServerName"
ProcessVM "ServerName"
ProcessVM "ServerName"
The Issue is the script runs on one server at a time. How do i get it to run on say a Value of servers at once say
Process=4
Any help would be greate
You can use the PowerShell Start-Job cmdlet to start each command as a seperate job.
Would you be able to Give me an example Sorry new to powershell and CLI
An example that also limits the number of concurrent jobs is:
$NumberOfConcurrentJobs = 4 Get-Content -Path Servers.txt | ForEach-Object { while ((Get-Job | Measure-Object).Count -gt $NumberOfConcurrentJobs) { Start-Sleep -Seconds 1 } Start-Job -ScriptBlock {ProcessVM $_} } Wait-Job
In the file servers.txt you have to specify the names of the vm's. One name on each line.
Thanks This way ill have to re-do my script it would take me a long time I try to find a new way thanks