Link
#Import-Module VMware.VimAutomation.Core
#如果使用 6.5.0 之前版本,需要先导入模块

Connect-VIServer -Server 192.168.1.1
#连接vCenter

$selectedlocation="Datacenter"
#此处可以设置 Datacenter 名称或者 Cluster 名称以限制范围

get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Start-VMHostService -Confirm:$false
get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Set-VMHostService -Policy "On" -Confirm:$false
#开启 SSH 服务并让 SSH 开机启动


#get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Stop-VMHostService -Confirm:$false
#get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM-SSH"} | Set-VMHostService -Policy "Off" -Confirm:$false
#关闭 SSH 服务并禁止 SSH 开机启动

#get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM"} | stop-vmhostservice -Confirm:$false
#get-vmhost -location $selectedlocation | Get-VMHostService | where {$_.key -eq "TSM"} | Set-VMHostService -Policy "Off" -Confirm:$false
#同时禁用 Technical support mode