Advertisement
PureGremlin

Disable-ESXSSH

Apr 21st, 2022 (edited)
1,501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Disable-ESXSSH {
  2. #Stops and Disables SSH service on all hosts in a Vcenter
  3. param ($vcenter,$cred)
  4. Write-Output "Connecting to $vcenter"
  5. Connect-VIServer -Server $vcenter -Credential $cred | out-null
  6. foreach ($vmhost in (get-vmhost | sort name)) {
  7.  
  8. Get-VMHostService -VMHost $vmhost | ? {$_.Key -eq "TSM-SSH"} | tee -Variable s | Set-VMHostService -Policy off|Stop-VMHo
  9. stService  -Confirm:$false
  10. }
  11. Disconnect-VIServer $vcenter -Confirm:$false
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement