davehull / Kansa

A Powershell incident response framework
Apache License 2.0
1.56k stars 266 forks source link

Kansa Core: Consider using PSRunspaces over PSSessions #131

Open jt-msft opened 9 years ago

jt-msft commented 9 years ago

Boe Prox has some sample code and a few blog posts about PSRunspaces that make them seem like a much more performant option for multithreading collection activities.

http://learn-powershell.net/2012/05/10/speedy-network-information-query-using-powershell/ http://learn-powershell.net/2014/06/11/norcal-powershell-user-group-presentation-on-runspaces-is-available/ https://github.com/proxb/PoshRSJob

secabstraction commented 9 years ago

In powershell v4 Invoke-Command implements runspace jobbing for you ;) If you're talking about remote collections. It does speed up Wmi queries quite effectively though. I know you already have this, but here's a simpler version I wrote: https://gist.github.com/secabstraction/4044f4aadd3ef21f0ca9 I wrote a simple wrapper for Wmi queries if you're interested, Invoke-WmiRunspaceQuery, derived from boe's post above. https://gist.github.com/secabstraction/c484d61cbdec10261c5b