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

View File

@ -1,5 +1,5 @@
Filename,Description
add-firewall-rules.ps1, adds firewall rules to the given executables, requires admin rights
add-firewall-rules.ps1, adds firewall rules to the given executables (requires admin rights)
check-ipv4-address.ps1, checks the given IPv4 address for validity
check-mac-address.ps1, checks the given MAC address for validity
check-xml-file.ps1, checks the given XML file for validity
@ -20,6 +20,7 @@ empty-dir.ps1, empties the given directory
enable-crash-dumps.ps1, enables the writing of crash dumps
encrypt-file.ps1, encrypts the given file
generate-qrcode.ps1, generates a QR code
hibernate.ps1, enables hibernate mode for the local computer (requires admin rights)
inspect-exe.ps1, prints basic information of the given executable file
list-anagrams.ps1, lists all anagrams of the given word
list-automatic-variables.ps1, lists PowerShell automatic variables
@ -57,10 +58,10 @@ open-browser.ps1, starts the default Web browser
open-calculator.ps1, starts the calculator program
open-email-client.ps1, starts the default email client
play-beep.ps1, plays a beep sound
poweroff.ps1, halts the local computer (needs administrator rights)
poweroff.ps1, halts the local computer (requires admin rights)
query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
new-email.ps1, starts the default email client to write a new email
reboot.ps1, reboots the local computer (needs administrator rights)
reboot.ps1, reboots the local computer (requires admin rights)
reboot-fritzbox.ps1, reboots the FRITZ!box device
search-files.ps1, searches the given pattern in the given files
scan-ports.ps1, scans the network for open/closed ports

1 Filename,Description Filename Description
2 add-firewall-rules.ps1, adds firewall rules to the given executables, requires admin rights add-firewall-rules.ps1 adds firewall rules to the given executables (requires admin rights)
3 check-ipv4-address.ps1, checks the given IPv4 address for validity check-ipv4-address.ps1 checks the given IPv4 address for validity
4 check-mac-address.ps1, checks the given MAC address for validity check-mac-address.ps1 checks the given MAC address for validity
5 check-xml-file.ps1, checks the given XML file for validity check-xml-file.ps1 checks the given XML file for validity
20 enable-crash-dumps.ps1, enables the writing of crash dumps enable-crash-dumps.ps1 enables the writing of crash dumps
21 encrypt-file.ps1, encrypts the given file encrypt-file.ps1 encrypts the given file
22 generate-qrcode.ps1, generates a QR code generate-qrcode.ps1 generates a QR code
23 hibernate.ps1 enables hibernate mode for the local computer (requires admin rights)
24 inspect-exe.ps1, prints basic information of the given executable file inspect-exe.ps1 prints basic information of the given executable file
25 list-anagrams.ps1, lists all anagrams of the given word list-anagrams.ps1 lists all anagrams of the given word
26 list-automatic-variables.ps1, lists PowerShell automatic variables list-automatic-variables.ps1 lists PowerShell automatic variables
58 open-calculator.ps1, starts the calculator program open-calculator.ps1 starts the calculator program
59 open-email-client.ps1, starts the default email client open-email-client.ps1 starts the default email client
60 play-beep.ps1, plays a beep sound play-beep.ps1 plays a beep sound
61 poweroff.ps1, halts the local computer (needs administrator rights) poweroff.ps1 halts the local computer (requires admin rights)
62 query-smart-data.ps1, queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory query-smart-data.ps1 queries the S.M.A.R.T. data of your HDD/SSD's and saves it to the current/given directory
63 new-email.ps1, starts the default email client to write a new email new-email.ps1 starts the default email client to write a new email
64 reboot.ps1, reboots the local computer (needs administrator rights) reboot.ps1 reboots the local computer (requires admin rights)
65 reboot-fritzbox.ps1, reboots the FRITZ!box device reboot-fritzbox.ps1 reboots the FRITZ!box device
66 search-files.ps1, searches the given pattern in the given files search-files.ps1 searches the given pattern in the given files
67 scan-ports.ps1, scans the network for open/closed ports scan-ports.ps1 scans the network for open/closed ports

View File

@ -7,7 +7,7 @@ List of Scripts
---------------
The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfolder:
* [add-firewall-rules.ps1](Scripts/add-firewall-rules.ps1) - adds firewall rules for the given executables
* [add-firewall-rules.ps1](Scripts/add-firewall-rules.ps1) - adds firewall rules for the given executables (requires admin rights)
* [check-ipv4-address.ps1](Scripts/check-ipv4-address.ps1) - checks the given IPv4 address for validity
* [check-mac-address.ps1](Scripts/check-mac-address.ps1) - checks the given MAC address for validity
* [check-xml-file.ps1](Scripts/check-xml-file.ps1) - checks the given XML file for validity
@ -28,6 +28,7 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [enable-crash-dumps.ps1](Scripts/enable-crash-dumps.ps1) - enables the writing of crash dumps
* [encrypt-file.ps1](Scripts/encrypt-file.ps1) - encrypts the given file
* [generate-qrcode.ps1](Scripts/generate-qrcode.ps1) - generates a QR code
* [hibernate.ps1](Scripts/hibernate.ps1) - enables hibernate mode for the local computer (requires admin rights)
* [inspect-exe.ps1](Scripts/inspect-exe.ps1) - prints basic information of the given executable file
* [list-anagrams.ps1](Scripts/list-anagrams.ps1) - lists all anagrams of the given word
* [list-automatic-variables.ps1](Scripts/list-automatic-variables.ps1) - lists PowerShell automatic variables
@ -64,11 +65,11 @@ The following PowerShell scripts can be found in the [Scripts/](Scripts/) subfol
* [open-calculator.ps1](Scripts/open-calculator.ps1) - starts the calculator program
* [open-email-client.ps1](Scripts/open-browser.ps1) - starts the default email client
* [play-beep.ps1](Scripts/play-beep.ps1) - plays a beep sound
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (needs administrator rights)
* [poweroff.ps1](Scripts/poweroff.ps1) - halts the local computer (requires admin rights)
* [query-smart-data.ps1](Scripts/query-smart-data.ps1) - queries the S.M.A.R.T. data of your HDD/SSD's
* [new-email.ps1](Scripts/new-email.ps1) - starts the default email client to write a new email
* [next-joke.ps1](Scripts/next-joke.ps1) - gets the next random Juck Norris joke
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (needs administrator rights)
* [reboot.ps1](Scripts/reboot.ps1) - reboots the local computer (requires admin rights)
* [reboot-fritzbox.ps1](Scripts/reboot-fritzbox.ps1) - reboots the FRITZ!box device
* [search-files.ps1](Scripts/search-files.ps1) - searches the given pattern in the given files
* [scan-ports.ps1](Scripts/scan-ports.ps1) - scans the network for open/closed ports

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
}

View File

@ -1,7 +1,7 @@
#!/snap/bin/powershell
<#
.SYNTAX ./reboot.ps1
.DESCRIPTION reboots the local computer, administrator rights are required
.DESCRIPTION reboots the local computer (requires admin rights)
.LINK https://github.com/fleschutz/PowerShell
.NOTES Author: Markus Fleschutz / License: CC0
#>