Created
October 27, 2020 16:26
-
-
Save boertel/47bb5c7cd66a405cdcf0168068db055b to your computer and use it in GitHub Desktop.
Task Scheduler for power mgmt 07:00 to 22:00
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$DateTimeNow = Get-Date | |
$DateTimeMorning = Get-Date -Hour 7 -Minute 0 | |
$DateTimeNight = Get-Date -Hour 22 -Minute 0 | |
| |
# 07:00 < now < 22:00 | |
| |
if ($DateTimeNow.TimeOfDay -gt $DateTimeMorning.TimeOfDay -and $DateTimeNow.TimeOfDay -lt $DateTimeNight.TimeOfDay) { | |
powercfg.exe /S SCHEME_MIN | |
} else { | |
powercfg.exe /S SCHEME_BALANCED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SCHTASKS /Create /F /SC ONLOGON /TN "logon_check" /TR "PowerShell.exe -ExecutionPolicy Bypass -File C:\subscripts\check_power.ps1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment