VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

VMs where the "tag" called Backup* is NOT setup

Hello

I need VMs where the "tag" called Backup is NOT setup

 

I can get vms with said Tag

Get-VM | Get-TagAssignment |where{$_.Tag -like 'Backup*'} | Select @{N='VM';E={$_.Entity.Name}}, tag

Please suggest how can i modify above for the end goal above ?

 

Thanks

Kiran

 

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VM |
where{$_.PowerState -eq 'PoweredOn' -and -not (Get-TagAssignment -Entity $_ | where{$_.Tag.Name -eq 'Tag1'})} |
Select Name


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

View solution in original post

2 Replies
esxi1979
Expert
Expert
Jump to solution

tried below no luck

 

Get-VM  | Where { $_.PowerState –eq 'PoweredOn' } | Get-TagAssignment |where{$_.Tag -like ''} | Select @{N='VM';E={$_.Entity.Name}}

 

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try something like this

Get-VM |
where{$_.PowerState -eq 'PoweredOn' -and -not (Get-TagAssignment -Entity $_ | where{$_.Tag.Name -eq 'Tag1'})} |
Select Name


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