Automation

 View Only
  • 1.  getting the host information

    Posted Feb 08, 2023 06:16 PM

    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!



  • 2.  RE: getting the host information
    Best Answer

    Posted Feb 08, 2023 06:50 PM

    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.



  • 3.  RE: getting the host information

    Posted Feb 08, 2023 08:08 PM

    That works perfect. tysm!



  • 4.  RE: getting the host information

    Posted Feb 09, 2023 09:50 AM

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