Created
June 10, 2024 17:04
-
-
Save mahdilamb/e7ce15baa3e9d9f9a3ce77266badb1a8 to your computer and use it in GitHub Desktop.
Hibernate the computer after a number of seconds. Format: `mm:ss`
This file contains hidden or 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
| param($DURATION) | |
| $_POS = $DURATION.IndexOf(":") | |
| $MINS = $DURATION.SubString(0, $_POS) | |
| $SECS = $DURATION.SubString($_POS + 1, $DURATION.Length - [Int64]$_POS - 1) | |
| $TOTAL_SECS = (([Int64]$MINS) * 60) + $SECS | |
| $REMAINING_SECS = $TOTAL_SECS | |
| while ($REMAINING_SECS -gt 0) { | |
| Write-Host -NoNewLine "`rSleeping after $REMAINING_SECS seconds" | |
| Start-Sleep -s 1 | |
| $REMAINING_SECS-- | |
| } | |
| Write-Host "" | |
| Write-Host "Done" | |
| shutdown /h |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment