PowerShell: Shut Down the Computer
Need to shut down a machine as part of a script, remotely, or without going through the Start menu? This one-liner shuts it down directly from the terminal.
Prerequisites:
- Privileges: Run as Administrator (for shutting down remote machines; not required for the local machine as a standard user in most cases)
- Module: Built-in, no import needed
Quick Command:
Stop-Computer -Force
📦
Want all of them at once?
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
Get every free one-liner from this blog in a single downloadable bundle organized by category, each with full comment-based help. No more copy-pasting one at a time.
How It Works:
- Stop-Computer shuts down the local machine.
- -Force forces applications to close and the shutdown to proceed immediately, rather than waiting or prompting.
- Without -Force, the shutdown may be delayed or blocked if applications have unsaved changes or are otherwise preventing it.
Pro Tip:
To shut down a remote computer instead of the local one, add -ComputerName:
Stop-Computer -ComputerName "RemotePC" -Force