Information
Enable normal lockdown mode on the ESXi host. Enabling lockdown mode deactivates direct access to an ESXi host and requires that the host be managed remotely from vCenter Server. This is done to ensure that the roles and access controls implemented in vCenter are always enforced, and users cannot bypass them by logging into a host directly. By forcing all interactions to occur through vCenter Server, the risk of someone attaining elevated privileges or performing tasks that are not properly audited is greatly reduced. Note that users listed in the Exception Users list for each host are allowed to override lockdown mode and log in. By default, no users are present on the Exception Users list. There are three settings for lockdown mode: disabled, normal, and strict. Choosing strict means that if the ESXi host loses contact with vCenter Server, it cannot be managed in any way until that connection is restored. If the connection cannot be restored, the host will need to be rebuilt. This level of lockdown mode is typically not necessary for most deployments and can present significant operational challenges. Therefore, we recommend using normal lockdown mode.
Solution
(Get-View (Get-VMHost -Name $ESXi | Get-View).ConfigManager.HostAccessManager).ChangeLockdownMode('lockdownNormal')