cjabates
Contributor
Contributor

Shut down VDI environment via PowerCLI

I'm trying to put together a script that will gracefully shut down my entire virtual environment, including Horizon VDI.

I've got the server VM side taken care of (already have that scripted), but getting Horizon shut down properly is a tougher nut to crack.

I've got the following code snippets which disable the pools and put the hosts into InstantClone Maintenance mode, but I still need to shut down the VDI VMs.

# get the pool names and disable them

$pools = get-hvpoolsummary
$poolnames = $pools.DesktopSummarydata.name

foreach ($dtp in ($poolnames)) {
    set-hvpool -poolname $dtp -disable -whatif
    set-hvpool -poolname $dtp -stop -whatif
}


foreach ($vdihost in Get-VMHost) {
    Set-Annotation -Entity $vdihost -CustomAttribute 'InstantClone.Maintenance' -Value '1' 
}

Or am I just overthinking shutting the VDI sessions down?

 Thanks in advance!

 

Chris

0 Kudos
1 Reply
fabio1975
Expert
Expert

Ciao 

It could be assumed to export the list of VMs belonging to the desktop pool and connect, again with powercli, to the vcenter where they are registered and turn them off from there.

 

Fabio 

Fabio
BLOG: https://vmvirtual.blog

if satisfied give me a kudos
0 Kudos