VMware Cloud Community
CypherBHV
Contributor
Contributor

VM host shudown via PowerCLI cmdlet

We are trying to shut down a ESXi host server via a PowerCLI command. The command is triggered by an APC Smart UPS that is connected via USB to one of the guest VMs on the host server.

The cmdlet we use is as follows:

Add-PSSnapin VMware.VimAutomation.Core
Connect-VIServer 10.192.72.1 -User "xxx" -Password "xxx"
Stop-VMHost 10.192.72.1 -RunAsync -Force -Confirm:$false
Disconnect-VIServer -Confirm:$false

The command is obviously triggered correctly by the UPS, but the shutdown of the server and VMs doesn't work as expected. We have two guest VMs on the server. After the command gets triggered one of the guest VMs gets shut down, the other guest VM does not. The host server itself also doesn't shut down (probably because the guest VM doesn't shut down properly?).

We have used the exact same command on a bunch of other host servers in exactly the same setup. It always worked fine. Yet on this machine it doesn't. And I'm running out of ideas as to why.

VMWare tools are installed on both guest servers, autostart is activated. The host server has ESXi 7.0.3 installed.

Does anyone have an idea?

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

Normally you should place the node first in maintenance mode.
And you could first shutdown the powered on VMs.

An alternative is to use the Force switch on the Stop-VMHost cmdlet, but that is risky if you still have running VMs.


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

Reply
0 Kudos
CypherBHV
Contributor
Contributor

We have been able to find the cause for our issue.

I had installed an outdated version of PowerCLI (6.0.0). After updating to the newest available version (12.4.1) and some tweaks to the script (didn't need the first line, had to add a line to ignore a certificate error we received when trying to connect to the ESXi) everything worked as expected.

It seems there may have been some changes to ESXi in Version 7.0.3 that don't work with the outdated PowerCLI anymore.

Reply
0 Kudos