On a related research, I stumbled upon the WMI Class Win32_OperatingSystem which comes with a method Win32ShutdownTracker.
The documentation for the Win32Shutdowntracker() method is available here: https://msdn.microsoft.com/en-us/library/aa394057(v=vs.85).aspx
It takes four parameters as explained below:
So the code to Force Restart a remote machine becomes:
(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer).Win32Shutdowntracker(0, "This is a custom comment", 0x00000000, 6)
Adding Credentials through a PScredential object is now easy:
(Get-WmiObject -Class Win32_OperatingSystem -ComputerName $Computer -Credential $CustomCredentials).Win32Shutdowntracker(0, "This is a custom comment", 0x00000000, 6)
Restart-Computerindicates that it uses the WMIWin32Shutdownmethod. You may be able to build upon the similarWin32ShutdownTrackermethod that does incluse comment and reason.