You may use the following VMware PowerCLI script to exit a VMware ESXi host out of maintenance mode.

<# .SYNOPSIS This script will exit a VMware ESXi host out of maintenance mode. .DESCRIPTION This script will exit a VMware ESXi host out of maintenance mode. .EXAMPLE Set-VMHost -VMhost HOST.DOMAIN.COM -State Connected. .AUTHOR Written by Noel Enrique Alvarez on Monday, April 15, 2019. #>

#Request the hostname of the VMware ESXi host
$HOSTNAME = Read-Host “What is the hostname of the VMware ESXi host?”

#Exit the VMware ESXi host out of maintenance mode
Set-VMHost -VMhost $HOSTNAME -State Connected

#End of script