Skip to content

Instantly share code, notes, and snippets.

@BerkeKaragoz
Last active May 29, 2022 16:03
Show Gist options
  • Save BerkeKaragoz/2f54d80d1245257f5d8bd8f4146a8756 to your computer and use it in GitHub Desktop.
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)
$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