I suspect that might pose a problem
When the ESXi is not connected to the vCenter, the Get-VMHostService might not work.
There are 2 alternatives imho
1) Connect to each ESXi host with the Connect-VICenter cmdlet, and once connected restart the service in the same way as I have shown
2) Connect to the iLO interface.
If I remember correctly there is a PowerShell library for that.
But I'm not sure how you can use this to restart a service on the ESXi.