VMware Cloud Community
Sebbee
Contributor
Contributor

Stop-VMHost

Im confused about how to shut down my ESXI host.

Will this command (Stop-VMHost) also stop all running VM-guests gracefully?

Reply
0 Kudos
7 Replies
LucD
Leadership
Leadership

Is the ESXi node part of a cluster that has DRS enabled?

If it is not, the Stop-VMHost will come back with an error when there are powered on VMs on the node.

If you add the -Force parameter, the power off will take place, effectively killing, not a graceful shutdown, the active VMs.

Those VMs will be left with the 'Disconnected' indication.


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

Reply
0 Kudos
Sebbee
Contributor
Contributor

No, it's a standalone host.

So I need to do a "Stop-VMGuest" on every guest first?

My problem is that I want to initiate the shutdown via PowerCLI from one of the hosts running on that exact ESXI-host..

So... if I do "Stop-VMGuest " on all guests first, then I cant do the STOP-VMHOST  from anywhere 😛

 

Is there no way to "tell" esxi to shut-down but also power-off the guests gracefully?

Reply
0 Kudos
LucD
Leadership
Leadership

You can configure the autostart actions for a standalone ESXi node.

For example, this will tell the ESXi node to shutdown down the VMs gracefully when the node is powered off.

$esx = Get-VMHost -Name MyEsx

$auto = Get-View -Id $esx.ExtensionData.ConfigManager.AutoStartManager


$spec = New-Object VMware.Vim.HostAutoStartManagerConfig

$spec.Defaults = New-Object VMware.Vim.AutoStartDefaults

$spec.Defaults.Enabled = $true

$spec.Defaults.StopAction = [VMware.Vim.AutoStartAction]::guestShutdown

$auto.ReconfigureAutostart


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

Reply
0 Kudos
Sebbee
Contributor
Contributor

Hello, big thanks for your help!

It actually worked. It's so strange that the webgui still says that it wont do a graceful shutdown when I click shutdown without  being in maintenancemode, but it does anyway.


This is the output after running (yeah, I chickened out and powered down all manually except one I dont care about before testing 😛 )

Stop-VMHost -VMHost 192.168.1.8 -force -Confirm:$false

 

I also confimed in in the guest operating system:

dockerdebian:~$ last -x shutdown
shutdown system down 4.19.67 Sat Nov 9 14:39 - 14:48 (00:08)


But it still bugs me that pressing the shutdown-button in the gui gives this:

Reply
0 Kudos
Sebbee
Contributor
Contributor

Seems like inserting images doesnt work. And no edit button in this forum?

Success: https://i.imgur.com/PD6plQa.png

This pops up when pressing shutdown in gui, even tho AutoStartManger-policy is set: https://i.imgur.com/xVqelti.png

Reply
0 Kudos
LucD
Leadership
Leadership

That might be what the Force switch is doing.
I don't think you have that option in the Web Client.


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

Reply
0 Kudos
LucD
Leadership
Leadership

Editing an existing entry can be done via Actions.

edit.jpg

And adding images is in option in the edit window menu

image.jpg


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

Reply
0 Kudos