Last active
November 4, 2019 21:17
-
-
Save pizycki/3f59995d1849117c1dbfe566508625cc to your computer and use it in GitHub Desktop.
PowerShell wrapper for shutdown.exe
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
| function Shutdown-PC { | |
| param ( | |
| [int] $Minutes = 5 | |
| ) | |
| $seconds = 60 * $Minutes | |
| $exp = "shutdown /s /t $seconds" | |
| $exp | Write-Host | |
| $exp | Invoke-Expression | |
| if($LASTEXITCODE -eq 0){ | |
| Write-Host "The computer will be shut down in $Minutes minutes" | |
| } else { | |
| Write-Error "Something went wrong" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment