Hello
I want to write a script to get information about VM Name, Owner, Machine state and Tools Status, as I am a beginner in powershell I could not find any solution yet.
I know how to get the VM Name and Owner
Get-VM | Get-Annotation -CustomAttribute Owner | select AnnotatedEntity, Value
and how to find machine state and tools status
Get-VM | Select-Object -Property Name,@{N="State";E={$_.Guest.State}},@{N="ToolsStatus";E={$_.Guest.ExtensionData.ToolsStatus}}
unfortunately I don't find a way to merge the two requests together.
Can anyone help me please?
Regards.
SaPu
Try it like this
Get-VM | Select-Object -Property Name,@{N="State";E={$_.Guest.State}},
@{N="ToolsStatus";E={$_.Guest.ExtensionData.ToolsStatus}},
@{N="AnnotatedEntity";E={$attr.AnnotatedEntity}},
@{N="Owner";E={(Get-Annotation -Entity $_ -CustomAttribute "Owner").Value}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Try it like this
Get-VM | Select-Object -Property Name,@{N="State";E={$_.Guest.State}},
@{N="ToolsStatus";E={$_.Guest.ExtensionData.ToolsStatus}},
@{N="AnnotatedEntity";E={$attr.AnnotatedEntity}},
@{N="Owner";E={(Get-Annotation -Entity $_ -CustomAttribute "Owner").Value}}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Great, thanks a lot, exactly what I was looking for.