Hi.
In the KB about backup/restore of the ESXi configuration (https://kb.vmware.com/s/article/2042141#In_vSphere_PowerCLI), one detail is missing from the "powercli" section.
Before you can restore the config, using "Set-VMHostFrimware", you need to enable the SSH service. If SSH is disabled, result will be: 401 (Unauthorized)
Thats a good catch. it could be argued that anyone attempting this should know to enable this.
Maybe, but "401"?
If the powershell command is attempting to connect, the error should be "failed to connect to <ip>:<port>". But it seems that the powershell command aborts at an earlier stage. I would argue that the API/powershell should be able to return "412 SSH service not started" 😉