Skip to content

Instantly share code, notes, and snippets.

@bsdayo
Last active June 26, 2026 13:18
Show Gist options
  • Select an option

  • Save bsdayo/520a9186ca65af08139ee04ee285227b to your computer and use it in GitHub Desktop.

Select an option

Save bsdayo/520a9186ca65af08139ee04ee285227b to your computer and use it in GitHub Desktop.
Enable only one display
# 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