LucD
Leadership
Leadership

Try something like this.
The variable $tagNames can contain 1 or more Tag names.

$tagNames = 'Tag1','Tag2','Tag3'

$vms = Get-VM -Tag $tagNames

$tagNames | ForEach-Object -Process {
  $vms = Get-VM -Tag $_ | where{$vms.Name -contains $_.Name}
}
$vms


How you populate the variable $tagNames is up to you. 


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post