restarting vpxa agent and then losing connection

This post was originally published on this site

I got the below script but after restarting vpxa agent, I think I lose connection and unable to conitnue and set the host back to connected. any idea?

 

 

param($vmhost)

 

# Put host in Maintenance mode and apply host profile

set-vmhost -vmhost $vmhost -state “Maintenance” -confirm:$false

Invoke-vmhostprofile $vmhost -confirm:$false | Test-VMhostprofilecompliance

# Restart watchdog service

#$esxhosts = get-vmhost -name (get-content esxhosts.txt)

#foreach ($vmhost in $esxhosts){}

$esxcli = get-esxcli -vmhost $vmhost -V2

$esxcli.hardware.ipmi.sel.clear.Invoke()

$esxcli.system.wbem.set.Invoke(@{enable=$false})

$esxcli.system.wbem.set.Invoke(@{enable=$true})

get-vmhostservice -vmhost $vmhost | ? {$_.Running -eq “True”} | restart-vmhostservice  -confirm:$false -ErrorAction Silentlycontinue

set-vmhost -vmhost $vmhost -state connected <——-

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.