connect-viserver -Server $vcenter -username $vcuser -password $vcpass|out-null Connect-SrmServer |out-null $report=@() $srmapi = $defaultsrmservers.ExtensionData $srmpgs = $srmapi.protection.listprotectiongroups() foreach ($pg in $srmpgs){ $pgname = $pg.GetInfo().Name $pgstate = $pg.GetProtectionState() $pgvms = $pg.ListProtectedVMs() $ArrayProp=[ordered]@{ 'Protection Group'=$pgname; 'Protection State'=$pgstate; 'Total VMs'=$pgvms.Count } for ($a=0; $a -lt $pgvms.Count; $a++) { $vm = get-vm -ID $pgvms[$a].VM.MoRef -ErrorAction SilentlyContinue $ArrayProp.Add("VM$($a) Name",$vm.Name) } $report += New-Object -TypeName psobject -Property $ArrayProp }