Added hibernate.ps1

This commit is contained in:
Markus Fleschutz
2021-02-06 12:20:28 +01:00
parent a7392aacc2
commit 56136da290
4 changed files with 27 additions and 7 deletions

18
Scripts/hibernate.ps1 Executable file
View File

@ -0,0 +1,18 @@
#!/snap/bin/powershell
<#
.SYNTAX ./hibernate.ps1
.DESCRIPTION enables hibernate mode for the local computer (requires admin rights)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>
#Requires -RunAsAdministrator
try {
[Void][System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.Windows.Forms.Application]::SetSuspendState("Hibernate", $false, $false);
exit 0
} catch {
write-error "ERROR in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
exit 1
}