You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently, the Stop-Computer cmdlet lacks native parameters for delayed shutdowns (-Timeout / -Delay) and audit-compliant shutdown reasons (-Reason / -Comment). System administrators who need to schedule maintenance with user grace periods or log structured reasons to the Windows Event Log (Event ID 1074) are forced to abandon idiomatic PowerShell and fall back to the legacy shutdown.exe command-line utility.
As a systems administrator managing Windows environments via PowerShell,
I want to specify a delay countdown, an audit reason, and a custom comment directly within the Stop-Computer cmdlet,
So that I can give active users advance notice before power-off and maintain accurate system event audit logs without relying on legacy shutdown.exe workarounds.
-Timeout / -Delay[int]: Time to wait (in seconds) before initiating the shutdown/restart.
-Comment[string]: User-readable message or banner text displayed to users and recorded in the event log.
-Reason[string](or enum): Standardized Windows shutdown reason code (e.g., PlannedMaintenance, UnplannedHardwareIssue, PlannedOperatingSystemReconfig) mapped to standard Windows Major:Minor reason codes.
This PR is awaiting to be merged that will bring delay, reason & comment to both Stop-Computer & Restart-Computer cmdlets but is currently only targeting these cmdlets on Windows.
I think all of these features can be implemented cross-platform
I'm not sure that they can. Or at least it was determined previously that it made sense to manage the internals of these commands in separate files, Computer.cs (for the Windows implementations) & ComputerUnix.cs (for non-Windows) due to different features that are available across platforms. Like for example on Windows we can make use of Windows API's.
Given the existing implementation I am not expecting much.
PS> Stop-Computer
Stop-Computer: The term 'shutdown' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Good POSIX practice is to not run programs as root until you absolutely need to, then you use sudo or equivalent to run that single command. So yes, /usr/sbin/shutdown does exist but I would not recommend running PowerShell as root, it is a bull-in-a-china-shop in comparison to nimble bash.
My recommendation would be that all cmdlets with nouns Computer or Service are removed from the codebase and relocated into separate repositories and hosted in PSGallery. There is no need for these cmdlets to share the same software-lifecycle of core PowerShell apart from for historical reasons.
Or shutdown or sudo actually don't exist.
alpine:~$ pwsh -version
PowerShell 7.6.1-0-gfeb892adb53cb138a59f135d98a77c4bb2fbdba5
alpine:~$ sudo su -
-sh: sudo: not found
alpine:~$ su -
Password:
alpine:~# shutdown -h now
-sh: shutdown: not found
alpine:~# poweroff
alpine:~# Connection to 192.168.64.13 closed by remote host.
In systemd-based distributions, the /usr/bin/shutdown is a symbolic link to systemctl.
shutdown --help:
This is a compatibility interface, please use the more powerful 'systemctl
halt', 'systemctl poweroff', 'systemctl reboot' commands instead.
Additionally, it is necessary to check for the presence of sudo, systemd-run (run0), or doas and determine whether elevated privileges are required to execute the command. For example, on Arch, these are not needed for the reboot, poweroff, and systemctl suspend commands.
Activity
soroshsabz commentedon Oct 7, 2026
I can provide PR for this too
soroshsabz commentedon Oct 7, 2026
I think all of these features can be implemented cross-platform
kilasuit commentedon Oct 8, 2026
This PR is awaiting to be merged that will bring delay, reason & comment to both
Stop-Computer&Restart-Computercmdlets but is currently only targeting these cmdlets on Windows.I'm not sure that they can. Or at least it was determined previously that it made sense to manage the internals of these commands in separate files, Computer.cs (for the Windows implementations) & ComputerUnix.cs (for non-Windows) due to different features that are available across platforms. Like for example on Windows we can make use of Windows API's.
soroshsabz commentedon Oct 8, 2026
Ryan Yates (@kilasuit) Ok, so after merging PR #27721 we can submit another PR to add Linux support
soroshsabz commentedon Oct 8, 2026
rhubarb-geek-nz commentedon Oct 8, 2026
Given the existing implementation I am not expecting much.
Good POSIX practice is to not run programs as root until you absolutely need to, then you use sudo or equivalent to run that single command. So yes,
/usr/sbin/shutdowndoes exist but I would not recommend running PowerShell as root, it is a bull-in-a-china-shop in comparison to nimble bash.My recommendation would be that all cmdlets with nouns Computer or Service are removed from the codebase and relocated into separate repositories and hosted in PSGallery. There is no need for these cmdlets to share the same software-lifecycle of core PowerShell apart from for historical reasons.
Or shutdown or sudo actually don't exist.
In Alpine's case we use 'poweroff'.
237dmitry commentedon Oct 8, 2026
In systemd-based distributions, the
/usr/bin/shutdownis a symbolic link tosystemctl.shutdown --help:Additionally, it is necessary to check for the presence of
sudo,systemd-run(run0), ordoasand determine whether elevated privileges are required to execute the command. For example, on Arch, these are not needed for thereboot,poweroff, andsystemctl suspendcommands.Exactly