$VMHosts = Get-VMHost

#SSH Service Status
$SSHServiceStatus = $VMHosts | Get-VMHostService | Where-Object Key -eq "TSM-SSH" | select VMhost,Key,Label,Running

#Disable SSH
ForEach($item in ($SSHService | Where-Object Running -eq $true)){
    Get-VMHost $item.VMHost | Get-VMHostService | Where-Object Key -eq "TSM-SSH" | Stop-VMHostService
}



#Lockdown status
$LockdownStatus = $VMHosts | Select Name,@{n='LockdownMode';e={$_.ExtensionData.Config.LockdownMode}}

#Enable Lockdown
ForEach($VMHost in ($LockdownStatus | Where-Object LockdownMode -eq "lockdownDisabled")){
    (Get-VMHost $VMHost.Name | Get-View).EnterLockdownMode()
}