Skip to content

About

PowerShell scripts for switching between predefined Windows display configurations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Windows Display Control

PowerShell scripts for switching between predefined Windows display configurations.

The project is designed primarily for my personal workstation and is triggered by keyboard macro keys. It uses the DisplayConfig PowerShell module to control the Windows display topology.

Profiles

The current configuration provides three display profiles:

  • Developer — two external Samsung monitors + laptop display.
  • Gaming — Samsung TV only.
  • Office — single external Samsung monitor.

The profiles are intentionally kept as small scripts that describe the desired display configuration. Common display detection and profile logic is contained in _DisplayFunctions.ps1.

Requirements

  • Windows
  • Windows PowerShell
  • DisplayConfig PowerShell module
  • The displays configured in _DisplayFunctions.ps1

Install the required PowerShell module with:

Install-Module -Name DisplayConfig

How it works

Windows does not always assign the same DisplayId to a physical display. For example, the ID assigned to the TV can change depending on whether the TV is powered on when Windows boots.

The project therefore does not permanently rely on DisplayId.

Instead, _DisplayFunctions.ps1 identifies each physical display using a stable substring of its Windows DevicePath, then resolves that display to its current DisplayId when the script starts.

The profile is then applied using the DisplayConfig module.

If a required display cannot be found, its DisplayId is set to 0 and the profile is not applied.

Changing or replacing a display

If a monitor, TV, laptop, or docking configuration is changed, the physical display identifiers may need to be updated.

Run:

Get-DisplayInfo | Format-List DisplayId, DisplayName, DevicePath

Find the DevicePath corresponding to the new display.

For example:

DisplayId   : 3
DisplayName : SAMSUNG
DevicePath  : \\?\DISPLAY#SAM0FEE#5&1a965fe7&0&UID4657#{...}

The identifier used by _DisplayFunctions.ps1 can be any unique substring of the DevicePath. For example:

Tv = Get-DisplayIdByDevicePath "UID4657" -DefaultDisplayId 0

If the chosen substring is no longer unique after replacing hardware, use a longer substring from the DevicePath.

Project structure

.
├── _DisplayFunctions.ps1
├── developer.ps1
├── gaming.ps1
├── office.ps1
├── developer.bat
├── gaming.bat
└── office.bat

_DisplayFunctions.ps1 contains the common functions, display identification and configuration.

The individual .ps1 files define the desired display profiles.

The .bat files are entry points used by the keyboard macro keys.

Personal Project / Disclaimer

This is a personal project, created primarily to automate display switching on my own Windows workstation.

It is published publicly because the code may be useful as a reference for other people looking for a similar solution. It is not intended to be a general-purpose, production-ready display management tool.

There is no commitment to:

  • backwards compatibility;
  • API stability;
  • regular maintenance;
  • issue resolution;
  • feature requests;
  • or compatibility with future versions of Windows, PowerShell, DisplayConfig, or other hardware.

The project is maintained when I need to change or improve something for my own setup. Consequently, breaking changes may be introduced at any time if they make sense for my use case.

If you use this project, you should expect that you may need to adapt the scripts to your own hardware and configuration.

AI-Assisted Development

A significant portion of this project was developed with the assistance of AI, including code generation, debugging, refactoring, documentation, and research.

The code has been reviewed and tested by the author and reflects the author's own requirements and decisions. AI assistance does not imply that the code is guaranteed to be correct, secure, or compatible with other environments.

License

Licensed under the Apache License 2.0.

If you use this repository as a reference, you are responsible for adapting and testing the code for your own system.

About

PowerShell scripts for switching between predefined Windows display configurations.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages