Skip to content

Instantly share code, notes, and snippets.

@pizycki
Last active November 4, 2019 21:17
Show Gist options
  • Select an option

  • Save pizycki/3f59995d1849117c1dbfe566508625cc to your computer and use it in GitHub Desktop.

Select an option

Save pizycki/3f59995d1849117c1dbfe566508625cc to your computer and use it in GitHub Desktop.
PowerShell wrapper for shutdown.exe
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