VMware Cloud Community
fun2dsw
Contributor
Contributor
Jump to solution

snapshot list with VM Name when Get-Snapshot FT -Property VM is empty

Hi all,

We can retrieve a Snapshot List in Powercli with

Get-VM | Get-Snapshot | Where {$_.SizeGB -gt 0} | FT -Property VM, Name, {[System.Math]::Round($_.SizeGB, 2)}, Created

But when the VM is powered off long enough or has no VMware Tools installed, FT -Property VM is empty, so we cannot see the VM name.

How to display the original name from Get-VM which is piped into Get-Snapshot ?

Thanks in advance

Ralph

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

No clue.

As an experiment, can you run the following?

It obtains the VM in 3 different ways.

Get-VM | Get-Snapshot |

Select Name,

    @{N='VM1';E={$_.VM.Name}},

    @{N='VM2';E={(Get-View -Id $_.VMID).Name}},

    @{N='VM3';E={(Get-View -Id $_.ExtensionData.VM).Name}}

Also, can you provide some information on where and with what you run this?

Platform, PS version, PowerCLI version?


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

View solution in original post

0 Kudos
11 Replies
LucD
Leadership
Leadership
Jump to solution

Retrieving the snapshot name has afaik nothing to do with the VM being powered on or with VMware Tools being installed.

I have never seen what you describe happen.

Could be something else in that VM that is causing this?

Can you recreate the issue?


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

0 Kudos
fun2dsw
Contributor
Contributor
Jump to solution

It's not the snapshot name, that is empty,

it's the VM-Name, see attached file...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Do you also see this when you run it like this?

Get-VM | Get-Snapshot | Where {$_.SizeGB -gt 0} |

Select -Property @{N='VM';E={$_.Vm.Name}},

    Name,

    @{N='SizeGB';E={[System.Math]::Round($_.SizeGB, 2)}},

    Created |

Format-Table


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

0 Kudos
fun2dsw
Contributor
Contributor
Jump to solution

Output see attached file...

(one blank to much in Your script @ Where {$ _.SizeGB ) between § and _ )

Seems like GET-Snapshot VM refers to DNS Name of VM while GET-VM delivers the VM-Name from VCENTER...

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That blank must have been introduced in your copy/paste, I don't see that.

And no, Get-Snapshot -VM definitely does not refer to the DNS name.


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

0 Kudos
fun2dsw
Contributor
Contributor
Jump to solution

we see the blank 🙂

Get-VM delivers the VM names, that we can see in Vcenter.

Get-Snapshot takes this as input, but delivers VM DNS Names, which can be empty.

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You must be in a parallel universe :smileygrin:

There is no blank, I just verified that with another user.

And the Get-Snapshot cmdlet has in the returned object, under the VM property a VirtualMachine object.
And in a VirtualMachine object, the Name property contains the DisplayName of the VM, not the DNS entry.


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

0 Kudos
fun2dsw
Contributor
Contributor
Jump to solution

Yeah, that parallel universe would also explain the blank outputs in our Get-Snapshot... 😄

So, how can it be blank then, as You can see in our outputs ???

A "Get-VM" delivers all the Display Names, no blanks there.

Regards,

Ralph

0 Kudos
LucD
Leadership
Leadership
Jump to solution

No clue.

As an experiment, can you run the following?

It obtains the VM in 3 different ways.

Get-VM | Get-Snapshot |

Select Name,

    @{N='VM1';E={$_.VM.Name}},

    @{N='VM2';E={(Get-View -Id $_.VMID).Name}},

    @{N='VM3';E={(Get-View -Id $_.ExtensionData.VM).Name}}

Also, can you provide some information on where and with what you run this?

Platform, PS version, PowerCLI version?


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

0 Kudos
fun2dsw
Contributor
Contributor
Jump to solution

Great job !!!

VM1 has blanks

VM2 and VM3 deliver the name !

Thanks a lot !

Informational:

Powercli 6.5 Release 1 build 4624819 running on Win7 with PSVersion 5.1.14409.1018

Regards,

Ralph

0 Kudos
LucD
Leadership
Leadership
Jump to solution

You should consider upgrading your PowerCLI version.


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

0 Kudos