Hi
How can I get a list of VMs that have a tag of the category "Location" and not present VMs that don't have this tag.
Get-TagAssignment -Entity $vm -Category "Location"
Will only list all tags.
I can't use: $vmlist = get-vm | Get-TagAssignment -Entity $vm -Category "Location"
And when I have this list, I of course want to filter on VMs from a specific location.... 🙂
Any tips?
Gabrie
Alternatively you can do it like this:
$tags = Get-Tag -Category "Location"
Get-VM -Tag $tags
Can't you do something like
Get-VM | Where {$_ | Get-TagAssignment | Where {$_.Tag.Category -eq "Location"}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Alternatively you can do it like this:
$tags = Get-Tag -Category "Location"
Get-VM -Tag $tags
Which is much more elegant than my Where-clause construction
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you both !!!