I’ve come up with a nice use-case for a task to run before making a terminal connection, but I can’t figure out how to configure this–if it’s even possible.
For any number of reasons, leaving SSH turned off on an ESXi host is a good idea, but there are times when you need to get on the host console to perform maintenance, like installing/uninstalling a VIB.
With a little PowerCLI, it’s pretty trivial to connect and turn on the SSH daemon, and I can do that before attempting to connect with Royal Terminal. But because Terminal connections allow for a “before connect” and “after connect” tasks, I thought it would be clever to do these things as part of the connection.
I can have the PowerCLI script in a .ps1 file, but it would be so much cleaner (not to mention portable!) if I could save it in a Command Task item. Being able to pass in the host FQDN, username, and password from the terminal config would be nice as well.
It’s unclear from documentation how one might go about doing this. For reference, here’s the code for enabling the daemon that I want to execute:
$pwd = ConvertTo-SecureString '$PASSWORD$' -AsPlainText -Force
$cred = New-Object System.Management.Automation.PSCredential('$USERNAME$', $pwd)
Connect-VIServer -server $HOST$ -Credential $cred | Out-Null
get-VMHostService -VMHost $HOST$ | ?{$_.Label -eq 'SSH'} | Start-VMHostService | Out-Null