Hi ,
I try to run simple script of foreach-object parallel from : https://blogs.vmware.com/PowerCLI/2021/02/new-release-vmware-powercli-12-2.html
running powershell 7 , with powercli 13 build - 20829139
its look that nothing happened after running.
i am trying 2 script:
1-save the output to $listStorage.
2- runinng the original script without results:
$cred= Get-Credential
$conn = Connect-VIServer testvcsa.cpbu.com -Credential $cred
Function Execute-WithoutPcliContext
{
$vmlist= get-VM
$vmlist |ForEach-Object -Parallel {
(Get-VM -Name $_.Name -Server $using:conn).Name
}
}
or
$cred= Get-Credential
$conn = Connect-VIServer testvcsa.cpbu.com -Credential $cred
Function Execute-WithPcliContext
{
$pcliContext= Get-PowerCLIContext
$vmlist= get-VM
$vmlist |ForEach-Object -Parallel {
Use-PowerCLIContext -PowerCLIContext $using:pcliContext -SkipImportModuleChecks
(Get-VM -Name $_.Name ).Name
}
}