Last active
April 14, 2019 03:08
-
-
Save LHazy/73eb6f2380d3742f6b90321569fcee88 to your computer and use it in GitHub Desktop.
電源に接続してる時にハイパフォーマンスに変更するみたいなやつ
This file contains hidden or 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
| # 使用は自己責任で、一切責任は負いません。 | |
| # このプログラムは個人の利便性と参考のために公開しています。 | |
| # | |
| # 参考情報 | |
| # https://docs.microsoft.com/en-us/windows/desktop/power/power-policy-settings | |
| # https://devblogs.microsoft.com/scripting/use-powershell-to-detect-power-state-and-to-set-power-plan/ | |
| $powerOptionMap = @{ | |
| Balance = "381b4222-f694-41f0-9685-ff5bb260df2e"; | |
| Presentation = "3c0b10d2-7404-4a8a-885f-1791a2c9a075"; | |
| Standard = "a83ffe77-647e-45df-899e-cd3f4e2835a1"; | |
| Radiation = "bd42480c-12e8-4fef-8c7d-3ef6d7f878c9"; | |
| Saving = "fa32fd97-3cb4-449c-afb1-b4e821970da7"; | |
| High = "8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c"; | |
| } | |
| $batteryStatus = (Get-CimInstance win32_battery).BatteryStatus | |
| if ($batteryStatus -eq 2) { | |
| # バッテリー接続時はハイパフォーマンス | |
| powercfg -setactive $powerOptionMap.High | |
| } elseif ($batteryStatus -eq 1) { | |
| # 放電中は標準 | |
| powercfg -setactive $powerOptionMap.Standard | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment