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
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
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
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}}
Indeed, I corrected the code above.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference