Trying to launch multiple "start-process" for a powercli script

Hi guys,

I'm trying to launch multiple "start-process" for a powercli script but can't seem to get the powercli commands to work.  Here is the script:

$path = "c:\temp\VMWARE"

$VC_List = "$path\VC_List.txt"

$Cluster_List = "$path\Cluster_List.txt"

$script = "C:\scripts\VMWare\test.ps1"

add-pssnapin VMware.VimAutomation.Core

. 'C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1'

$vCenters = Get-Content $VC_List

foreach ($vc in $vCenters)


connect-viserver $vc

get-cluster | select -ExpandProperty name | out-file $Cluster_List

$Clusters = Get-Content $Cluster_List

foreach ($cluster in $clusters)


        $powershellArguments = "$script", "*", "day", "3", "95", "c:\temp\$cluster.csv"

        Start-Process -filepath "powershell.exe" -ArgumentList $powershellArguments -NoNewWindow



It just bleeds red and I think it has something to do with "Initialize-PowerCLIEnvironment.ps1"

Basically, I'm trying to launch a PowerCli script in parallel for each cluster on multiple vCenter servers because the script itself is too slow to complete.

Here are a few errors:

get-vm : The term 'get-vm' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or

Let me know what you think.


Tags (1)
0 Kudos
1 Reply

I would strongly suggest to upgrade your PowerCLI version!

The latest version don't have PSSnapin anymore (which combined with module autoloading is very handy), and they don't have the init .ps1 file anymore.

Why do you want to go for Start-Process instead of Start-Job?

From my previous experiments in that realm (RunSpaces), I'm not even sure PowerCLI is multi-thread safe.

Blog:  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos