Managing services on esxi host systems from powercli, starting tsm-ssh

by Grzegorz Kulikowski

What if you wanted to check status of some particular service on the host system. For example, you need to login via ssh to all of your esxi boxes in myCluster1.
Let’s check status of remote Tech support ssh service
[sourcecode language=”powershell”]
Get-Cluster -Name "myCluster1" | get-vmhost | Get-VMHostService | ? {$_.Key -eq "TSM-ssh"}
Key Label Policy Running Required
— —– —— ——- ——–
TSM-SSH Remote-Support (SSH) off True False
TSM-SSH Remote-Support (SSH) off False False
TSM-SSH Remote-Support (SSH) off False False
This is the default output. We do not see on which host the ssh is turned on or off
We can quickly add it to our output:
[sourcecode language=”powershell”]
Get-Cluster -Name "myCluster1" | get-vmhost | % {$vhost=$; get-VMHostSErvice -VMHost $_ | ? {$_.Key -eq "TSM-ssh"}|select @{N="Host";E={$vhost}}, @{N="Service";E={$_.Key}},Running,Policy }

Host Service Running Policy
—- ——- ——- ——
host1 TSM-SSH True off
host2 TSM-SSH True off
host3 TSM-SSH True off
Above line will do what is needed, but i just realized that this not efficient as there is no need to do this approach. VMhost property is included in each service object. So we can just simply use below line.
[sourcecode language=”powershell”]
Get-Cluster -Name "UPCAT WIN CLuster" | get-vmhost | Get-VMHostService | ? {($_.Key -eq "TSM-ssh")} |select VMHost, Key,Label, Running
To check what servieces are avaialable on host :
[sourcecode language=”powershell”]
get-vmhost "vmhost1" |Get-VMHostService|select Key,Label
Now if you want to start for example TSM-SSH service, for all hosts in cluster
[sourcecode language=”powershell”]
Get-Cluster -Name "myCluster1" | get-vmhost | Get-VMHostService | ? {($_.Key -eq "TSM-ssh") -and ($_.Running -eq $False)} | Start-VMHostService
So we are looking for tesm-ssh services wich are not currently running and piping them to Start-VMHostSErvice.

As you can see it is very easy to manipulate host system services from powercli.

You may also like

Leave a Reply

Chinese (Simplified)EnglishFrenchGermanHindiPolishSpanish
Streaming live on Twitch right now.