Tuesday, September 12, 2017

Enabling and Disabling SSH on ESXi hosts via PowerCLI scripts

Enabling and Disabling SSH on ESXi hosts via PowerCLI scripts

Enable SSH on Particular ESXi
Get-VMHost -Name esxi_server1,esxi_server2 | Foreach {Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}

Disable SSH on Particular ESXi
Get-VMHost -Name esxi_server1,esxi_server2 | Foreach {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}

SSH status on Particular ESXi
Get-VMHostService -VMHost esxi_server1,esxi_server2 | Where-Object {$_.Key -eq "TSM-SSH"}

Enable SSH on all ESXi
Get-VMHost | Foreach { Start-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}

Disable SSH on all ESXi
Get-VMHost | Foreach {Stop-VMHostService -HostService ($_ | Get-VMHostService | Where { $_.Key -eq "TSM-SSH"} )}

SSH status on all ESXi
Get-VMHost | Get-VMHostService | Where { $_.Key -eq "TSM-SSH" } |select VMHost, Label, Running

No comments:

Post a Comment