PowerCLI: Enable/Disable SSH and Lockdown Mode

Today I will show you quick and easy way to enable and disable SSH and Lockdown mode for all hosts in the cluster.

Let’s start by connecting to vCenter:

Connect-VIServer vcenter_hostname_or_IP

Next let’s grab list of hosts in the cluster and put it to variable

$Lhosts = Get-Cluster -Name AngrySysOps.com | Get-VMHost

Now we will disable SSH

$Lhosts | Get-VMHostService | Where Key -EQ "TSM-SSH" | Stop-VMHostService

To enable SSH change Stop-VMHostService to Start-VMHostService

Lockdown Mode – disable

foreach ($h in $Lhosts) {
    ($Lhosts | Get-View).ExitLockdownMode()
    }

To enable change ExitLockdownMode to EnterLockdownMode

Please like and share to spread the knowledge in the community.

Visit my FB page: https://www.facebook.com/AngrySysOps

Subscribe to my YouTube channel: https://www.youtube.com/channel/UCRTcKGl0neismSRpDMK_M4A

Please leave the comment