VMware Cloud Community
David2021
Contributor
Contributor
Jump to solution

Try to get the Guest OS in a snapshot inventory

Hello,

I try to find some help to get the Guest OS not the configured OS for each vm which have a snapshot.

 

Get-VM | Get-Snapshot |

select Name,

Created,

@{N="RunningOS";E={

$s = Get-View -Id $_.ExtensionData.Guest.GuestFullName -Property GuestFullName

while($s -and $s -isnot [vmview.guest.guestfullname]){

$s = Get-View -Id $s.GuestFullName -Property GuestFullName

}

if($s){

$s.GuestFullName

}

}},

 

regards,

David

 

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

My bad, that should start from the VM property.

Get-VM | Get-Snapshot |
select Name,Created,@{N="RunningOS";E={$_.VM.ExtensionData.Guest.GuestFullName}}


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

View solution in original post

Reply
0 Kudos
9 Replies
LucD
Leadership
Leadership
Jump to solution

Did you try with

Get-VM | Get-Snapshot |
select Name,Created,@{N="RunningOS";E={$_.ExtensionData.Guest.GuestFullName}}


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

Reply
0 Kudos
David2021
Contributor
Contributor
Jump to solution

Hello LucD,

Your proposition is not working.

I try with

#$s = Get-Vm | Get-View -Property "Guest.GuestFullName

#while($s -and $s -isnot [vmview.Guest.GuestFullname]){

# $s = select -Property Guest.GuestFullName

# }

# if($s){

# $s.GuestFullName

#}

#}},

 

but not works also I think Get-view is not appropriate in my case. I'm lost for the moment

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

In the snippet I posted I didn't use Get-View, but ExtensionData.
The snippet in your last reply is all commented out.
Not sure what the meaning of that last reply is.


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

Reply
0 Kudos
David2021
Contributor
Contributor
Jump to solution

Hello,

I'm sorry LucD I forgot to remove # on each line when I reply on this post but without it's always not working.

If I understand your last reply I have to found the right extension data. because your proposition with Guest.GuestFullName is not working. When I extracted  data for runningOS is blank.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Even when you remove the comments , that is not what I posted


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

Reply
0 Kudos
David2021
Contributor
Contributor
Jump to solution

Hello LucD,

 

when I tried:

Get-VM | Get-Snapshot |
select Name,Created,@{N="RunningOS";E={$_.ExtensionData.Guest.GuestFullName}}

or

Get-VM | Get-Snapshot |
select Name,Created,@{N="RunningOS";E={$_.ExtensionData.Config.GuestFullName}}

None data appear on RunningOS column

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

My bad, that should start from the VM property.

Get-VM | Get-Snapshot |
select Name,Created,@{N="RunningOS";E={$_.VM.ExtensionData.Guest.GuestFullName}}


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

Reply
0 Kudos
David2021
Contributor
Contributor
Jump to solution

 LucD,

It's working now. It's exactly that I would like.

Thanks a lot

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You might want to mark the thread as answered, which makes it easier for others to find threads that have an answer.


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

Reply
0 Kudos