Add lock-desktop.ps1 and suspend.ps1

This commit is contained in:
Markus Fleschutz
2022-06-09 16:12:40 +02:00
parent d042c48c42
commit 969a457a15
5 changed files with 50 additions and 13 deletions

21
Scripts/suspend.ps1 Normal file
View File

@ -0,0 +1,21 @@
<#
.SYNOPSIS
Suspends the computer
.DESCRIPTION
This PowerShell script suspends the local computer immediately.
.EXAMPLE
PS> ./suspend
.LINK
https://github.com/fleschutz/PowerShell
.NOTES
Author: Markus Fleschutz | License: CC0
#>
try {
"Bye bye."
& rundll32.exe powrprof.dll,SetSuspendState 0,1,0 # bHibernate,bForce,bWakeupEventsDisabled
exit 0 # success
} catch {
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}