-
Notifications
You must be signed in to change notification settings - Fork 5
shutdown_toggle.ps1
Corey Watson edited this page Dec 1, 2025
·
1 revision
Shutdown Toggle with Warning.
Schedules a system shutdown with a warning message, or cancels an existing scheduled shutdown if one is already pending. Acts as a toggle - run once to schedule, run again to cancel.
This script provides a safe way to remotely schedule or cancel system shutdowns with user warnings. The toggle behavior allows technicians to easily cancel an accidental shutdown by simply running the script again.
- Windows 10/11 or Windows Server
- Administrator privileges
- shutdown.exe (standard Windows component)
-
$shutdownTime: Time in seconds before shutdown (default: 60)
- Checks if a shutdown is already scheduled
- If scheduled: Cancels the pending shutdown
- If not scheduled: Schedules a new shutdown with warning message
- User sees on-screen countdown before shutdown
- No secrets in logs
- Shutdown can be canceled by running script again
-
0= Success (shutdown scheduled or canceled) -
1= Failure
[ INPUT VALIDATION ]
--------------------------------------------------------------
Shutdown Time : 60 seconds
[ CHECKING SHUTDOWN STATUS ]
--------------------------------------------------------------
Pending Shutdown : None detected
[ SCHEDULING SHUTDOWN ]
--------------------------------------------------------------
Command : shutdown /s /t 60
Warning message displayed to user
Shutdown scheduled in 60 seconds
[ FINAL STATUS ]
--------------------------------------------------------------
Result : SHUTDOWN SCHEDULED
Run this script again to cancel
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
[ INPUT VALIDATION ]
--------------------------------------------------------------
Shutdown Time : 60 seconds
[ CHECKING SHUTDOWN STATUS ]
--------------------------------------------------------------
Pending Shutdown : DETECTED
[ CANCELING SHUTDOWN ]
--------------------------------------------------------------
Executing : shutdown /a
Shutdown canceled successfully
[ FINAL STATUS ]
--------------------------------------------------------------
Result : SHUTDOWN CANCELED
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
- v1.0.0 (2024-12-01) - Initial release - migrated from SuperOps
- View Script Source
- Scripts - Back to script index