Well, this post is all about doing some administration tasks using “VMware PowerCLI“.
1. Remote TSM (SSH)
Think about conditions you’ve added 30 new hosts to your vCenter and for some reasons you want to enable remote access (SSH) on all these hosts; there are multiple ways like:
1. Enabling this option from “DCUI” by local access or using remote server management option (iLO/DRAC)
2. Enabling this option one by one on all hosts using vSphere Client (ServerConfigurationSecurity ProfileServices)
3. Or better and faster way would be running one little script to do it for you
bellow you can find the related script which will let you enable remote access (Remote TSM) on all hosts connected to one VMware vCenter server.
# Getting vCenter server information (IP/DNS) $VCSrv = Read-Host ("Which vCenter server do you want to connect") # Getting credential for connection $cred = Get-Credential # Connecting to the vCenter Server Connect-VIServer -Server $VCSrv -Credential $cred # Getting list of available hosts $VMHosts = Get-VMHost | Sort-Object Name # Viewing current state of "Remote TSM (SSH)" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} # Enabling service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Set-VMHostService -Policy On
Also for disabling “Remote TSM” on all hosts you can change last line on above script with bellow line.
# Disabling service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Set-VMHostService -Policy Off
Up to now, you just enabled or disabled this service but you might want to run or stop it as well, so bellow you can find two related commands:
# Starting "Remote TSM (SSH)" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Start-VMHostService # Stopping "Remote TSM (SSH)" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM-SSH"} | Stop-VMHostService
2. Local TSM
Sometimes you might need to have a local access on your “VMware ESXi” host(s) for troubleshooting, maintenance or other task, in these cases you can enable local TSM on each host one by one or running one little script which will take care of this for you.
# Getting vCenter server information (IP/DNS) $VCSrv = Read-Host ("Which vCenter server do you want to connect") # Getting credential for connection $cred = Get-Credential # Connecting to the vCenter Server Connect-VIServer -Server $VCSrv -Credential $cred # Getting list of available hosts $VMHosts = Get-VMHost | Sort-Object Name # Viewing current state of "Local TSM" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} # Enabling service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Set-VMHostService -Policy On
After finishing that task you might want to disable it 😉 , so here the related script for disabling this feature on all hosts, just replace this line with last line on above script.
# Disabling service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Set-VMHostService -Policy Off
Just like, “Remote TSM” you have enabled/disabled service but not start or stop it yet, bellow you can find related code:
# Starting "TSM" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Start-VMHostService # Stopping "TSM" service Get-VMHostService -VMHost $VMHosts | where {$_.Key -eq "TSM"} | Stop-VMHostService
3. TSM related warning
All hosts which have this feature enabled on them, would show a below warning if you connect to them by vSphere Client.
Again, for fixing this problem there is multiple ways, here are two of them:
1. Change one “Host Advance Configuration” value from 0 to 1 (ServerConfigurationAdvanced SettingsUserVarsUserVars.SuppressShellWarning)
2. Or running script which is much faster and easier
Bellow you can find related script which would disable this warning on hosts with “Remote TSM (SSH)” enabled on them.
# Getting vCenter server information (IP/DNS) $VCSrv = Read-Host ("Which vCenter server do you want to connect") # Getting credential for connection $cred = Get-Credential # Connecting to the vCenter Server Connect-VIServer -Server $VCSrv -Credential $cred # Getting list of available hosts $VMHosts = Get-VMHost | Sort-Object Name # Disabling TSM related warning Set-VMHostAdvancedConfiguration -VMHost $VMHosts -Name "UserVars.SuppressShellWarning" -Value 1
For security reasons, you might be notified when this feature enabled on any host so you can do opposite and enabling this warning by bellow command.
# Enabling TSM related warning Set-VMHostAdvancedConfiguration -VMHost $VMHosts -Name "UserVars.SuppressShellWarning" -Value 0
Note:
#1. For running above services run line “#2” and for stopping them run line “#5” one each section.