Home automation tools like Home Assistant offer convenient integrations for remotely shutting down computers with Windows OS (and also re-powering on via WOL, triggering a power switch etc).
To get the shutdown feature running, you need to prepare some simple steps on the Windows client.
Trying the first time you might encounter one of these error messages:
Could not initialise pipe winreg. Error was NT_STATUS_OBJECT_NAME_NOT_FOUND
- Create a separate local Windows user which is used only for this purpose (shutting down the machine), like “remoteShutdown” with the same password (not your usual one, as this might be stored on the calling system).
- (Optional) Assign user to the local Administrators group
- Run “secpol.msc” and assign the user to the object which allows Remote Shutdown
- Note that even if the user Administrator is already listed there, it might not work with it. This is why we created the new user.
- Configure Windows Firewall to allow Remote Shutdown and WMI, you find both properties in “Allowed apps”.
- Make sure “Remote Registry” service is enabled (automatic) and running.