I am a (relatively) recent convert to get-view due to the amazing increase in speed for running PowerCLI scripts across hundred of ESXi hosts / thousands of VMs.
I've been struggling with how to do this with a supplied list of VMs? What I want to do is with a supplied list of VMs get the hardware version and tools version.
Normally if you wanted a report of everything you'd do the following:
get-view -viewtype VirtualMachine -property Name, Config | select Name, @{N="HWVersion";E={$_.Config.Version}},@{N="Tools";E={$_.Config.Tools.ToolsVersion}} | ft -auto
Now reading up on -filter is seems the way to go - but it only uses a hashtable. ie "Name" = "Foo". It doesn't seem to handle "Name"=$vmList where $vmList is a collection of mulitple VMs. I won't go into how if the variable is a single VM that Foo matches Foo and FooBar.
What I've used is the following:
$vmList = get-content c:\scripts\import\listofvms.txt
get-vm $vmList | get-view -property Name, Config | select Name, @{N="HWVersion";E={$_.Config.Version}},@{N="Tools";E=$_.Config.Tools.ToolsVersion}} | ft -auto
The only problem is I feel like this is a workaround - that this should all be doable using get-view directly. So - if I wanted to use -filter with a collection of VMs how would I go about doing that?
Cheers
Robert