Bulk powershell remoting made easy with parallelexecution module

Write-host "hello world"

During the last months, with the help of Alvaro Jimenez & Raul Carboneras i have been working on a new powershell module to simplify the administration of multiple Windows systems using Powershell. (For v2 we will look into incorporating Linux systems using PS core)

The idea is quite simple but powerfull. Let explain it with an example.

We start by running:

$results=Get-ADDomainController -filter * | select -ExpandProperty hostname | Start-ParallelExecution -Command "get-service" -Verbose

The previous command get the list of all domain controllers in a domain (as objects), get from it the hostnames, and finally use that as input for the start-parallelexecution command, the core of this module, that in this case runs a single command, get-service to retrieve the list of services on each machine. All that runs as Powershell jobs through remoting sessions in parallel so can handle hundreds of machines in a matter of seconds.

The results are stored in $results, if we investigate $results we will see is a hashtable with one entry per machine, each entry containing an object that stores the result of the execution of the command as one property. That means we can do things like...

$results.'rootdc1.contoso.com'.results | where{$_.name -eq "ADWS"}

To see if the ADWS service is running on rootdc1

Or even better

$results.values.results | where{$_.name -eq "ADWS"}

To see in which machines that service exists.

Go ahead and give it a try. It supports using multiple credentials for different domains, copying prerequisites to destination machines (for example to copy custom modules that are later on referenced), using scripts instead of commands for more complicated tasks, specifying multiple command using a csv file (what about documenting an infrastructure on a single command...), redirecting to an xml file for future reference, and much more...

The code is now on the powershell gallery so you can install it on any Powershell 5 system with Internet running "install-module parallelexecution" you can also download it from here


The source code is available on github



Hope you find it useful!