I've learned enough around here to compose the below scriptlet that will find VMs on specific datastores and attached to specific port groups but have been failing for hours trying to add another variable without exiting the loop and re-scanning all VM's again.
I need the get-VM command to also include get-annotation | ?{$_.Value -eq "backedup"} and also return on the results so the output looks like:
Parent Datastore Annotation
VMname Datastore1 backedup
get-cluster | ?{$_.Name -notlike "*lab*"} | get-vmhost | Get-Datastore | ?{$_.Name -notlike "*ISO*" -and $_.Name -notlike "*templates*"} | Foreach-Object {
$ds = $_.Name
$_ | Get-VM | Get-NetworkAdapter | ?{$_.NetworkName -like "Backup Network"} | Select-Object Parent,@{n='DataStore';e={$ds}}
}
any assistance would be appreciated.