# dot source the function into our session
. ".\Invoke-Parallel.ps1"
# Get full help details
Get-Help Invoke-Parallel -full
# Create PSObject array
$pstablelist = @();
invoke-parallel -InputObject $(get-content .\ServerIps.txt) -throttle 100 -runspaceTimeout 30 -ScriptBlock {
$ping = Test-Connection -ComputerName $_ -count 1
# Create a Hash table where the contents of key are the column names that will be exported to CSV,
# and the contents of value are the values that will be exported to CSV
$table = @{"ComputerName"=$_;"Ping"=$ping;};
# Convert the Hash table to PSObject
$pstable = New-Object -TypeName PSObject -Prop $table;
# Insert the converted PSObject into the array and wait for the output
$pstablelist += $pstable;
}
$pstablelist | Export-Csv .\Output.csv -NoTypeInformation