SaPu
Contributor
Contributor

Get Information about VM Name, Owner, Machine state and Tools Status

Jump to solution

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

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership

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

View solution in original post

0 Kudos
2 Replies
LucD
Leadership
Leadership

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

View solution in original post

0 Kudos
SaPu
Contributor
Contributor

Great, thanks a lot, exactly what I was looking for.

0 Kudos