Last active
March 8, 2022 21:16
-
-
Save ra101/c2060ade52280b4fcbe3291331caf1e0 to your computer and use it in GitHub Desktop.
Script to control brightness via command
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
$brightness = (Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightness).CurrentBrightness | |
if ($args[0] -eq "desc") { | |
$brightness = (([int]($brightness / 10) * 10 - 10), 0 | Measure -Max).Maximum | |
} | |
else { | |
$brightness = (([int]($brightness / 10) * 10 + 10), 100 | Measure -Min).Minimum | |
} | |
(Get-WmiObject -Namespace root/WMI -Class WmiMonitorBrightnessMethods).WmiSetBrightness(1, $brightness) | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is all that I get when I run the code.
Get-WmiObject : Not supported
At C:\users\dbuch\desktop\brightness.ps1:1 char:16
Get-WmiObject : Not supported
At C:\users\dbuch\desktop\brightness.ps1:10 char:2
You cannot call a method on a null-valued expression.
At C:\users\dbuch\desktop\brightness.ps1:10 char:1