Reply to Message

View discussion in a popup

Replying to:
MattHumphreys
Contributor
Contributor

Thanks for that LucD, that gives me a list of VM's that matches any of the tags in $tagnames, I am looking to get to a list that contains only the VM's that match all of the tags, I have reluctantly come to the conclusion just for expediency that I will have to manually enter the tag information:

 

Get-VM | Select Name,@{Name="Tags";Expression={(Get-TagAssignment -Entity $_).Tag.Name}} |
Where {$_.Tags -match "Tag1" -and $_.Tags -match "Tag2" -and $_.Tags -match "Tag3" -and $_.Tags -notmatch "Tag4"} |
Format-Table -Autosize

 

It gives me the response I wanted and allows me to do things like exclude based on a particular tag or with a tag combination.

 

The reason for the whole thing is we are using veeam and tag combinations to group machines into backups but veeam doesnt easily display a list of VM's that are captured by the tag combination so I am doing this to get me a list to ensure that everything is correct before the backups run.

Reply
0 Kudos