VMware Cloud Community
vivekrishna
Enthusiast
Enthusiast

View PowerCli Script for extracting the current snapshot from horizon machine

Hi Team,

I would like to export a document containing the Horizon Virtual machines both (Dedicated and Floating) and their corresponding snapshots.

 

I tried the below command, but it will be good if i get the info for whole Horizon VDI machines, not on the base of pool.

 

$pool = Get-HVPool -PoolName xxxxx

This will get you the path of the gold image

$pool.AutomatedDesktopData.VirtualCenterNamesData.ParentVmPath

This will get you the path to the snapshot

$pool.AutomatedDesktopData.VirtualCenterNamesData.SnapshotPath

 

 

Thanks,

 

Vivek

0 Kudos
4 Replies
LucD
Leadership
Leadership

Did you try like this?

Get-HvPool |
Select @{N='Pool';E={$_.Base.Name}},
    @{N='Snapshot';E={$_.AutomatedDesktopData.VirtualCenterNamesData.SnapshotPath}}


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

0 Kudos
vivekrishna
Enthusiast
Enthusiast

I got the Pool - Snapshot details by using the below script. But I need Machine - Snap data (Not pool wise)

$pooldata=@()

foreach ($pool in $pools){

$pooldata+=new-object PSObject -property @{"name" = $pool.base.name;

"ParentVM"= $pool.AutomatedDesktopData.VirtualCenterNamesData.ParentVmPath.substring(($pool.AutomatedDesktopData.VirtualCenterNamesData.ParentVmPath.LastIndexOf("/")+1));"Snap"= $pool.AutomatedDesktopData.VirtualCenterNamesData.SnapshotPath.substring(($pool.AutomatedDesktopData.VirtualCenterNamesData.SnapshotPath.LastIndexOf("/")+1));
}
}
$pooldata

0 Kudos
LucD
Leadership
Leadership

You should be able to do that in a loop.

Get-HVPool -PipelineVariable pool |
ForEach-Object -Process {
    Get-HVMachineSummary -PoolName $pool.Base.Name |
    Select @{N='Machine';E={$_.base.name}},
        @{N='Pool';E={$pool.Base.Name}},
        @{N='User';E={$_.namesdata.username}},
        @{N='Status';E={$_.Base.BasicState}},
        @{N='Type';E={$_.Base.Type}},
        @{N='Snapshot';E={$pool.AutomatedDesktopData.VirtualCenterNamesData.SnapshotPath}}
}


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

Magneet
Hot Shot
Hot Shot

The vCheck for Horizon has a plugin that checks if machines are on the correct snapshot, maybe you can use that as base

 

https://github.com/vCheckReport/vCheck-HorizonView/blob/master/Plugins/20%20Desktop/10%20Automated%2...