From cf3dbd051f34910078cd42bb3149289bedc7b34c Mon Sep 17 00:00:00 2001 From: Markus Fleschutz Date: Sat, 20 Aug 2022 12:43:49 +0200 Subject: [PATCH] Update poweroff.ps1 --- Scripts/poweroff.ps1 | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Scripts/poweroff.ps1 b/Scripts/poweroff.ps1 index 124db89d..478b6709 100755 --- a/Scripts/poweroff.ps1 +++ b/Scripts/poweroff.ps1 @@ -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 { - Stop-Computer + if ($IsLinux) { + sudo shutdown + } else { + Stop-Computer + } exit 0 # success } catch { "⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"