VMware Cloud Community
Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

getting the host information

I have  a script that checks for snapshots and it runs fine. I would like to also have the hostname of snapshot included, but i don't see it in a get-help get-snapshot. Can the hostname be retireved from this command?

 

$snaps = Get-VM| Get-Snapshot| select VM, Name, Description, Created, SizeGB

 

Thank you!

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | 
Get-Snapshot| 
select @{N='VMHost';E={$_.VM.VMHost.Name}},
   @{N='VM';E={$_.VM.Name}},
   Name, Description, Created, SizeGB

But be aware that this is not necessarily the ESXi node where the VM was running when the snapshot was taken.
This is the ESXi node where that VM is currently running.


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

View solution in original post

3 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VM | 
Get-Snapshot| 
select @{N='VMHost';E={$_.VM.VMHost.Name}},
   @{N='VM';E={$_.VM.Name}},
   Name, Description, Created, SizeGB

But be aware that this is not necessarily the ESXi node where the VM was running when the snapshot was taken.
This is the ESXi node where that VM is currently running.


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

Squigglymonkey
Enthusiast
Enthusiast
Jump to solution

That works perfect. tysm!

Reply
0 Kudos
perkosret
Contributor
Contributor
Jump to solution

Will use it for my almost similar scrypt. Thank you. 

Reply
0 Kudos