In this blog, we will ensure we disable SSH access on all our esx hosts
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
##################################################################### # Ensure SSH is disabled # # Tested by Ash on 28 Oct # V1.0 ###################################################################### #Variables $vCenter = "sfo-m01-vc02.ash.local" $Cluster = "Production-vSAN" ### Start of Script # Load VMware Cmdlet and connect to vCenter Add-PSSnapin vmware.vimautomation.core connect-viserver -server $vCenter $VMHost = Get-Cluster -Name $Cluster | Get-VMhost # Check if SSH is running and set to start Get-VMHost | Get-VMHostService | Where { $_.key -eq "TSM-SSH" } | Select VMHost, Key, Label, Policy, Running, Required | ft # Pause for user input pause # Set SSH to start manually rather than automatically for all hosts ForEach ($VMhost in $Cluster){ Write-Host -ForegroundColor GREEN "Disable SSH Service on " -NoNewline Write-Host -ForegroundColor YELLOW "$VMhost" Get-VMHost | Get-VMHostService | Where { $_.key -eq "TSM-SSH" } | Set-VMHostService -Policy Off } ### End of Script |
(Visited 73 times, 1 visits today)