How to enable ESXi SSH And ESXi Shell Using PowerCLI

How to enable ESXi SSH And ESXi Shell Using PowerCLI

Connect to the VCenter Server


#Connect to VCenter Server 
Connect-VIServer -Server -Protocol https -User Administrator@vsphere.local -Password P@ssw0rd

#Now Check which serveries are running and you want to start or stop
Get-VMHost | Get-VMHostService

Now you will get slimier  to below screen

PowerCLI C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI> Get-VMHost | Get-VMHostService

Key                  Label                          Policy     Running  Required
---                  -----                          ------     -------  --------
DCUI                 Direct Console UI              on         True     False
TSM                  ESXi Shell                     on         False    False
TSM-SSH              SSH                            off        False    False
lbtd                 lbtd                           on         True     False
lsassd               Local Security Authenticati... off        False    False
lwiod                I/O Redirector (Active Dire... off        False    False
netlogond            Network Login Server (Activ... off        False    False
ntpd                 NTP Daemon                     automatic  True     False
sfcbd-watchdog       CIM Server                     on         True     False
snmpd                snmpd                          on         True     False
vprobed              vprobed                        off        False    False
vpxa                 vpxa                           on         True     False
xorg                 xorg                           on         False    False

Now Select the service key for the service which you want to start or stop
For example If I want to stop SSH service I will take key TSM-SSH

For one Server I will give below command

Get-VMHost | Get-VMHostService | where {$_.Key -eq "TSM-SSH"} | Stop-VMHostService
#For All ESXi Host on Cluster 
Get-VMHost | foreach { get-vmhostservice -VMHost $ | where {$_.Key -eq "TSM-SSH"} | Stop-VMHostService}

To Stop Service use         Stop-VMHostService
To Start Service use        Start-VMHostService

Your email address will not be published. Required fields are marked *