Last active
May 29, 2022 16:03
-
-
Save BerkeKaragoz/2f54d80d1245257f5d8bd8f4146a8756 to your computer and use it in GitHub Desktop.
Shuts down the PC without the pop-up warning after X minutes (Powershell)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$time = Read-Host -Prompt "Minutes to wait before shutdown" | |
$host.privatedata.ProgressForegroundColor = "white"; | |
while ($time -ne 1){ | |
Write-Progress "$time minutes left to shutdown. Close to cancel." | |
$time = $time - 1 | |
sleep 60 | |
} | |
$time = 60 | |
$host.privatedata.ProgressBackgroundColor = "darkred"; | |
while ($time -ne 0){ | |
Write-Progress "$time seconds left to shutdown. Close to cancel." | |
$time = $time - 1 | |
sleep 1 | |
} | |
$host.privatedata.ProgressBackgroundColor = "red"; | |
Write-Progress "Shutting down..." | |
shutdown -s -t 00 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment