Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 178257

vm query script help

$
0
0

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.


Viewing all articles
Browse latest Browse all 178257

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>