Files

44 lines
1.0 KiB
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Power Actions – Restart Explorer, Restart, Shutdown, Logoff, Sleep, Hibernate
# Host: silent
# Options: Restart Explorer; Restart PC; Shutdown PC; Log off; Sleep; Hibernate
param([string]$choice)
switch ($choice) {
"Restart Explorer" {
Write-Output "Restarting Explorer..."
Stop-Process -Name explorer -Force
Start-Process explorer.exe
}
"Restart PC" {
Write-Output "Restarting computer..."
Restart-Computer -Force
}
"Shutdown PC" {
Write-Output "Shutting down computer..."
Stop-Computer -Force
}
"Log off" {
Write-Output "Logging off current user..."
shutdown.exe /l
}
"Sleep" {
Write-Output "Putting system to sleep..."
rundll32.exe powrprof.dll,SetSuspendState 0,1,0
}
"Hibernate" {
Write-Output "Hibernating system..."
rundll32.exe powrprof.dll,SetSuspendState Hibernate
}
default {
Write-Output "Unknown option: $choice"
}
}