I want to run a T-SQL batch statement (select statement) in 1000+ servers. But if i run the script using regular powershell, it will take a long time as it will refer the serverlist .txt file to read each server entry, then it will call a powershell script where each server will be passed as a loop then the results will be copied to an output file.
Instead of that, I think to use PS thread where a bunch of 10 servers will be taken a at a time, so that the select statement which I want to run against the servers would be completed sooner.
There's a great into to the concept at [url]http://learn-powershell.net/2012/05/13/using-background-runspaces-instead-of-psjobs-for-better-performance/
I've also got background runspaces heavily used in [url]https://sqlpowerdoc.codeplex.com/[/url] – feel free to look at the code and use the relevant parts as needed to get up to speed on how runspaces work.