VMware Cloud Community
esxi1979
Expert
Expert
Jump to solution

get-vm |Get-Annotation

Hi,

@LucD  thanks for the help on below code ..

Get-VM |
Where{(Get-Annotation -Entity $_ -Customattribute 'OS', 'LOB').Value.Foreach{ $_ -eq '' } -contains $true} |
Select Name

 

In above code, what if  i wanted to get more details of such vms eg its cluster , datacenter 

get-vm |Get-Annotation  , i know only gives limited info ie name,  AnnotatedEntity & value

Please suggest

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

You can use calculated properties on the Select-Object cmdlet to retrieve additional information, starting from the VM object.
Something like this for example

 

Get-VM |
Where{(Get-Annotation -Entity $_ -Customattribute 'OS', 'LOB').Value.Foreach{ $_ -eq '' } -contains $true} |
Select Name,
    @{N='Cluster';E={(Get-Cluster -VM $_).Name}},
    @{N='Datacenter';E={(Get-Datacenter -VM $_).Name}}

 


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

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

You can use calculated properties on the Select-Object cmdlet to retrieve additional information, starting from the VM object.
Something like this for example

 

Get-VM |
Where{(Get-Annotation -Entity $_ -Customattribute 'OS', 'LOB').Value.Foreach{ $_ -eq '' } -contains $true} |
Select Name,
    @{N='Cluster';E={(Get-Cluster -VM $_).Name}},
    @{N='Datacenter';E={(Get-Datacenter -VM $_).Name}}

 


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

esxi1979
Expert
Expert
Jump to solution

there was a missing _ in datacenter ..

 

Get-VM |
Where{(Get-Annotation -Entity $_ -Customattribute 'OS', 'LOB').Value.Foreach{ $_ -eq '' } -contains $true} |
Select Name,
@{N='Cluster';E={(Get-Cluster -VM $_).Name}},
@{N='Datacenter';E={(Get-Datacenter -VM $_).Name}}

 

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Indeed, I corrected the code above.


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

0 Kudos