troubleshooting Question

powershell - How to speed up script on multiple servers

Avatar of String :-)
String :-)Flag for Australia asked on
8 Comments2 Solutions63 ViewsLast Modified:
Much of my work involves runnning scripts against multiple servers. This morning for example I had to reset IIS on 48 servers:
Whilst this script works just fine, it is quite slow because it waits for each server in the list to complete the task before moving on to the next one.

foreach ($server in (Get-Content "D:\Deployment\_ServerLists\AppServers.txt")){

Invoke-Command -cn $Server -ScriptBlock { iisreset.exe -Restart }

Is there anyway to tell powershell to invoke-command to each server concurrently but still writing output to transcripts  (I tried running each asjob, but then I lost the output of what it was doing).

cheers for any tips!.
String :-)
Join our community to see this answer!
Unlock 2 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros