I am trying to upgrade a host from 6.5 to 6.7 asnd then applying all ciritical and non critical updates. I think I will need 2 separate tasks for this?
import-module Vmware.VimAutomation.Core
import-module Vmware.Vumautomation
$vmhost = read-host "enter hostname that needs to be patched"
write-host ""
if ($vmhost.ConnectionState -eq "connected") {
Set-VMHost -VMHost $vmhost -State Maintenance -Confirm:$false
}
Get-Baseline -Name "Cisco C240S ESXi 6.7U1 upgrade" | Attach-Baseline -entity $vmhost -Confirm:$false
Scan-Inventory -Entity $vmhost
get-baseline -name "Cisco C240S ESXi 6.7U1 upgrade" | Remediate-Inventory -Entity $vmhost -Confirm:$false -ErrorAction SilentlyContinue
start-sleep -s 300
if ($vmhost.ConnectionState -eq "connected") {
Set-VMHost -VMHost $vmhost -State Maintenance -Confirm:$false
}
Get-Baseline -Name *Critical* | Attach-Baseline -entity $vmhost -Confirm:$false
Scan-Inventory -Entity $vmhost
get-baseline -name *Critical* | Remediate-Inventory -Entity $vmhost -Confirm:$false -ErrorAction SilentlyContinue
the script seems to be stuck after the host is upgraded. but does not proceed to getting the latest patches/updates. Also after the host comes back online after upgrade it takes it out of maintenance mode immediately. why is that?