Good afternoon-
I'm looking for a way to list all VMs that have multiple tags from a certain category. In my situation, I'm using VMware tags to control the selection lists for my backup software. I have a tag category called "Backup Job" and tags called "Monday," "Tuesday," etc. I'm looking for a script that will tell me all the VMs that have multiple tags from the Backup Job category, like the "Monday" and "Thursday" tags, for example.
Thank you!
Try something like this
$tagCatName = 'Backup Job'
$tagCat = Get-TagCategory -Name $tagCatName
Get-VM | where {(Get-TagAssignment -Entity $_ -Category $tagCat).Count -gt 1} |
Select Name,
@{N="Tags";E={[string]::Join(',',(Get-TagAssignment -Entity $_ -Category $tagCat | %{$_.Tag.Name}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try something like this
$tagCatName = 'Backup Job'
$tagCat = Get-TagCategory -Name $tagCatName
Get-VM | where {(Get-TagAssignment -Entity $_ -Category $tagCat).Count -gt 1} |
Select Name,
@{N="Tags";E={[string]::Join(',',(Get-TagAssignment -Entity $_ -Category $tagCat | %{$_.Tag.Name}))}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
PERFECT!! Thank you so much!!