Recently we came across a situation where when we try to put a ESXi host in Maintenance Mode, it is getting stuck at certain level. These ESXi nodes were part of a vSphere with Tanzu 7 U3 cluster. While troubleshooting we noticed that there are some VMs that are either orphaned or inaccessible running on it. We deleted those orphaned and inaccessible VMs and then the ESXi node enters Maintenance Mode successfully.
You can use VMware PowerCLI to list those orphaned and inaccessible VMs.
(Get-VMHost <host_fqdn> | Get-VM | Where {$_.ExtensionData.Summary.Runtime.ConnectionState -eq "orphaned"}) | select Name,Id,PowerState
(Get-VMHost <host_fqdn> | Get-VM | Where {$_.ExtensionData.Summary.Runtime.ConnectionState -eq "inaccessible"}) | select Name,Id,PowerState
We then deleted those orphaned and inaccessible VMs. You can try to delete them using Remove-VM command.
Remove-VM -VM <vm_name> -DeletePermanently
If that does not work, you can try with dcli.
dcli> com vmware vcenter vm delete --vm <vm-id>
Hope it was useful.