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
No clue.
As an experiment, can you run the following?
It obtains the VM in 3 different ways.
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
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
Do you also see this when you run it like this?
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
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
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.
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
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
No clue.
As an experiment, can you run the following?
It obtains the VM in 3 different ways.
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
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
You should consider upgrading your PowerCLI version.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference