You could simply pass your entire array to Invoke-Command without using New-PSSession first. It will handle the queue behind the scenes for you. For example, instead of this:
invoke-command -session $s -scriptblock {$net = new-object -ComObject WScript.Network} invoke-command -session $s -scriptblock {$drive = ls function:[g-z]: -n | ?{ !(test-path $_) } | select -first 1} invoke-command -session $s -scriptblock {$net.MapNetworkDrive($drive, "\\Mapped Network Location\Visio 2010", $false, "Domain\Username", "Password")} invoke-command -session $s -scriptblock {set-location $drive} invoke-command -session $s -scriptblock {.\setup.exe}
You could combine those separate calls to invoke-command into a single, multi-statement script block that is called against many computers:
Invoke-Command -ComputerName $hugeComputerArray -ScriptBlock { $net = New-Object -ComObject WScript.Network $drive = ls function:[g-z]: -n | ?{ !(Test-Path $_) } | select -first 1 $net.MapNetworkDrive($drive, "\\Mapped Network Location\Visio 2010", $false, "Domain\Username", "Password") Set-Location $drive .\setup.exe }