Update poweroff.ps1

This commit is contained in:
Markus Fleschutz 2022-08-20 12:43:49 +02:00
parent fe3cd68194
commit cf3dbd051f

View File

@ -1,20 +1,24 @@
<#
.SYNOPSIS
Halts the local computer (needs admin rights)
Halts the computer (needs admin rights)
.DESCRIPTION
This script halts the local computer. It needs admin rights.
This script halts the local computer immediately (needs admin rights).
.EXAMPLE
PS> ./poweroff
.NOTES
Author: Markus Fleschutz · License: CC0
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
#Requires -RunAsAdministrator
try {
if ($IsLinux) {
sudo shutdown
} else {
Stop-Computer
}
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"