May not be the fastest or most efficient but it was the first way that came to mind. foreach($vm in $vms){ # Check if VM is not in a cluster at all and report If(!(Get-Cluster -VM $vm))...
See more...
May not be the fastest or most efficient but it was the first way that came to mind. foreach($vm in $vms){ # Check if VM is not in a cluster at all and report If(!(Get-Cluster -VM $vm)){ $vm | Add-Member -MemberType NoteProperty -Name Cluster -Value "None" $vm | Add-Member -MemberType NoteProperty -Name DRSEnabled -Value "None" $vm | Select Name, Cluster, DRSEnabled, PowerState }Else{ # Since VM is in a cluster, check if DRS is enabled and report $cluster = Get-Cluster -VM $vm $vm | Add-Member -MemberType NoteProperty -Name Cluster -Value $cluster.Name $vm | Add-Member -MemberType NoteProperty -Name DRSEnabled -Value $cluster.DrsEnabled $vm | Select Name, Cluster, DRSEnabled, PowerState } }