Restart-Computer needs a parameter to give a reason for the restart
Would be interested in understanding the scenario where you are using the cmdlet & specifying the reason for rebooting. To explain: our previous assumption was that users would EITHER use the server UI that captured this information, OR use the cmdlet (often so they didn’t need to supply that reason text).
So, what would help is to understand in what situations the cmdlet is being used and specifying the reboot explanation is desirable.
As mentioned by others, it would be very helpful to specify any notes during shutdown / restart, which would be captured in event logs. When managing many servers, VMs, UI option is not suitable and not being able to use it in scripts is a big shortcoming.
We do a lot of scripting within our environment, and being able to specify the reason for a reboot along with text in the logs is important for us. At the moment we have to use shutdown with /c and /p to achieve this, which obviously doesn't give us the option for a "-WAIT -For", which we basically have to simulate in code.
Andy Ray commented
Frankly, until I started moving my workflows to PowerShell I was unaware that this feature was not available. I would have assumed with the richness of PowerShell this would have been a "given". Much as Luc has already explained, while it is very nice to have a quick method for restarting a system without the GUI, which is fine in labs and lower level domains, tracking restarts via the event log is a very common practice.
If the restart is admin initiated (EITHER by script or by GUI) - some notation on the local system can be a godsend if trying to track down issues. Admittedly, if it is voluntary or behaves like the GUI, you can largely skip through it and it does no one any good... but for "managed systems" it is proper hygiene.
Michael Halpin commented
Also, may want to capture info from a workflow "rebooting because of monthly patch task", etc
From a PowerShell script, you can use:
& shutdown /r /t 0 /c "Application xx updated." /d P:4:1
Luc FULLENWARTH commented
- Nano server.
- Administrators which are doing more than 90% of their work remotely via PS Sessions in ISE tabs don't wich to open a RDP session just to restart a server, especially if they have a bunch of servers to restart alltogether.
- Software or server management via script
- Restart-Computer -Wait -For WinRM is more user friendly than logging on to the server, use the GUI to restart, and then opening a shell to make a PING until the server is availlable.
When talking about "giving a reason" I don't just mean a category (planned application, ...) I also mean a manual comment. Usually I mention the ticket number (incident, planned change, ...) or a brief summary of my action (Reboot because the server was in this state or I was doing this or that).