mirror of
https://github.com/fleschutz/PowerShell.git
synced 2025-08-09 13:04:59 +02:00
Add lock-desktop.ps1 and suspend.ps1
This commit is contained in:
@ -1,23 +1,19 @@
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Enables hibernate mode for the local computer (needs admin rights)
|
||||
Hibernates the computer
|
||||
.DESCRIPTION
|
||||
This PowerShell script enables hibernate mode for the local computer. It needs admin rights.
|
||||
This PowerShell script enables hibernate mode for the local computer immediately.
|
||||
.EXAMPLE
|
||||
PS> ./hibernate
|
||||
.LINK
|
||||
https://github.com/fleschutz/PowerShell
|
||||
.NOTES
|
||||
Author: Markus Fleschutz / License: CC0
|
||||
Author: Markus Fleschutz | License: CC0
|
||||
#>
|
||||
|
||||
#Requires -RunAsAdministrator
|
||||
|
||||
try {
|
||||
[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
|
||||
[System.Windows.Forms.Application]::SetSuspendState("Hibernate", $false, $false);
|
||||
|
||||
"✔️ Done."
|
||||
"Bye bye."
|
||||
& rundll32.exe powrprof.dll,SetSuspendState 1,1,0 # bHibernate,bForce,bWakeupEventsDisabled
|
||||
exit 0 # success
|
||||
} catch {
|
||||
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||||
|
Reference in New Issue
Block a user