PowerCLI:批量停用ESXi主机的SSH服务

# 登录vCenter Server
Connect-VIServer -Server <vCenter IP> -user Administrator@vsphere.local -password <密码>
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false

# 查看SSH服务状态
$VMHost = Get-VMHost
foreach ($VMHost in $VMHost) {
   Get-VMHostService -VMHost $VMHost | where {$_.Key -eq "TSM-SSH"} | Select @{N="VMHost";E={$VMHost.Name}},Key,Running
  }

# 关闭SSH服务
$VMHost = Get-VMHost
foreach ($VMHost in $VMHost) {
   Get-VMHostService -VMHost $VMHost | where {$_.Key -eq "TSM-SSH"} | Stop-VMHostService -Confirm:$false
  }

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注