sequences - slow script

I wrote a simple script that scans over 200 machines to check the status of a couple of services. It stores the returned data in an array and at the end creates a csv and sens it to me. Trouble is the script runs for over 30 mins as it connects to each machine one by one. How would I make it to scan all the machines at once and then sort the data by hostname?

Edit: Can you post your code? Please do so between pre /pre tags.

Will you post your script? You may be running in serial rather than parallel. PowerShell Remoting must be enabled.

# Establish 32 concurrent connections at once (Parallel)
Invoke-Command -ComputerName (Get-Content serverlist.txt) {
     Get-Service yourservice   

# Execute for one computer then the next (Serial)
foreach ($c in (Get-Content serverlist.txt)) {
    Invoke-Command -ComputerName $c {Get-Service yourservice}}

I use the serial method

foreach($item in $comps){
   $status = invoke-command $item -scriptblock {get-service | where{$ -eq "my_service} | select -expandproperty status}
$x = @{
    cn = $item
    status = $status
$report += New-Object psobject -property $x
$report | select cn,status | export-csv $csv_file

You can use Invoke-Parallel script to ‘multithread’ your script using runs spaces…

Try something like this.

$comps = @('comp1','comp2','comp3')
Invoke-Command -ComputerName $comps {Get-Service myservice} | 
Select-Object Status,Name,DisplayName,PSComputerName | 
Export-Csv .\file.csv -NoTypeInformation

For a test I tried

$feature = Invoke-Command -ComputerName $comps {$env:computername; (Get-WindowsFeature feature1).installed}

Problem is when I get the results every now and then I’ll get a series of computernames followed by series of booleans rather than computername followed by the answer so it’s difficult to tell whether the boolean are in the same order like the computernames e.g.