Last active
June 26, 2026 13:18
-
-
Save bsdayo/520a9186ca65af08139ee04ee285227b to your computer and use it in GitHub Desktop.
Enable only one display
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
| # Install-Module DisplayConfig | |
| $target = $args[0] | |
| Write-Host "Switching to display `"$target`" only..." | |
| $targetId = (Get-DisplayInfo | Where-Object { $_.DisplayName -eq $target }).DisplayId | |
| if (!$targetId) { | |
| Write-Error "Display `"$target`" not found! Exiting..." | |
| exit 1 | |
| } | |
| Enable-Display -DisplayId $targetId | |
| Set-DisplayPrimary -DisplayId $targetId | |
| Get-DisplayInfo | Where-Object { $_.DisplayId -ne $targetId } | ForEach-Object { Disable-Display -DisplayId $_.DisplayId } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment