-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathGet-DisplayBrightness.ps1
56 lines (49 loc) · 1.41 KB
/
Get-DisplayBrightness.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
function Get-DisplayBrightness {
<#
.SYNOPSIS
To get the current brightness of the display
.DESCRIPTION
To get the current brightness of the display
.PARAMETER IncludeInput
Switch to display the full WMI path to the current value
.EXAMPLE
Get-DisplayBrightness
60
.EXAMPLE
Get-DisplayBrightness -IncludeInput
Namespace Class CurrentBrightness
--------- ----- -----------------
root/WMI WmiMonitorBrightness 60
.EXAMPLE
Set-Display -Brightness 100
Get-DisplayBrightness
100
.NOTES
Inspired by: https://community.idera.com/database-tools/powershell/powertips/b/tips/posts/check-monitor-brightness
#>
#region parameter
[CmdletBinding()]
[OutputType('int')]
param (
[switch] $IncludeInput
)
#endregion parameter
begin {
Write-Verbose -Message "Starting [$($MyInvocation.Mycommand)]"
}
process {
$Cim = Get-CimInstance -Namespace 'root/WMI' -Class 'WmiMonitorBrightness'
if ($IncludeInput) {
New-Object psobject -Prop ([ordered] @{
Namespace = 'root/WMI'
Class = 'WmiMonitorBrightness'
CurrentBrightness = $Cim.CurrentBrightness
})
} else {
write-output $Cim.CurrentBrightness
}
}
end {
Write-Verbose -Message "Ending [$($MyInvocation.Mycommand)]"
}
}