This PowerShell module allows you to manage various monitor settings on Windows computers.
Internal displays, like the ones found on laptops are managed with WMI and the only settings that can be adjusted are brightness related.
External displays connected via DisplayPort, HDMI, etc. are managed with DDC/CI. Most displays support DDC/CI, but in some cases it needs to be enabled from the On Screen Display.
For more information about DDC/CI, see: https://en.wikipedia.org/wiki/Display_Data_Channel
First, install the module from the PowerShell gallery: Install-Module MonitorConfig
Then check the available commands in the module: Get-Command -Module MonitorConfig
PS C:\> Get-Monitor
LogicalDisplay FriendlyName InstanceName
-------------- ------------ ------------
\\.\DISPLAY1 Dell S2417DG(DisplayPort) DISPLAY\DELA0E7\5&21071cf6&0&UID12547
\\.\DISPLAY2 Dell S2417DG(DisplayPort) DISPLAY\DELA0E7\5&21071cf6&0&UID12549
\\.\DISPLAY3 Generic PnP Monitor DISPLAY\GSM5788\5&21071cf6&0&UID12544Note that the friendlyname is provided by the monitor driver, which usually also includes a color profile.
PS C:\> Get-Monitor -DeviceName \\.\DISPLAY3 | Set-MonitorVCPValue -VCPCode 0xD6 -Value 4PS C:\> Get-Monitor -Primary | Get-MonitorVCPResponse -All
VCPCode Name CurrentValue MaxValue Description
------- ---- ------------ -------- -----------
0x00 Code Page 0 0 Returns the Code Page ID number Byte SL.
0x02 New Control Value 1 0 Indicates that a displays MCCS VCP Code register value has changed.
0x03 Soft Controls 0 0 Allows applications running on the host to use control buttons on the display.
0x04 Restore Factory Defaults 0 0 Restore all factory presets including luminance / contrast, geometry, color and TV defaults.
0x05 Restore Factory Luminance / Contras… 0 0 Restores factory defaults for luminance and contrast adjustments.
0x08 Restore Factory Color Defaults 0 0 Restore factory defaults for color settings.
0x10 Luminance 39 100 Luminance of the image (Brightness control).The module already includes a number of high level commands for managing common monitor settings like brightness and input source but what if you want to do more?
Then you'd use Get-MonitorVCPResponse and Set-MonitorVCPValue to read/write specific VCP code values.
These functions can be put inside wrapper functions with custom attributes to add the same completion/argument transformation as native MonitorConfig commands have.
Here's an example for making a function to change the power state:
function Set-CustomMonitorPowerState
{
Param
(
[Parameter(Mandatory, ValueFromPipeline, Position = 0)]
[ArgumentCompleter([MartinGC94.MonitorConfig.API.ParamAttributes.VCPDeviceNameCompleter])]
[MartinGC94.MonitorConfig.API.ParamAttributes.MonitorArgTransformer()]
[MartinGC94.MonitorConfig.API.VCP.VCPMonitor[]]
$Monitor,
[Parameter(Mandatory, Position = 1)]
[ValidateRange(1, 5)]
[uint32]
$PowerState
)
Process
{
$Monitor | Set-MonitorVCPValue -VCPCode 0xD6 -Value $PowerState
}
}Note the type along with the 2 custom attributes on the Monitor parameter. These will add the completion for string values like \\.\DISPLAY1 and the argument transformer needed to convert those same strings to actual monitor objects.