Get Active Window Titles

Code Properties

  • Language: PowerShell
  • Cmdlets: Get-Process

Overview

Sources:

PowerShell commands and script to get a list of active application windows with their process ID, name, and window title.

Code

One-liner:

Get-Process | Where-Object { $_.MainWindowTitle } | Format-Table Id, Name, MainWindowTitle -AutoSize

Retrieve only the window title by process ID:

(Get-Process -Id 8748 -ErrorAction SilentlyContinue).MainWindowTitle

Full script:

<#
  .SYNOPSIS
    Gets a list of active application windows with ID, Name, and MainWindowTitle
#>
[CmdletBinding()]
Param()
 
Begin {
    $Processes = Get-Process | Where-Object { $_.MainWindowTitle }
}
 
Process {
    $Processes | Format-Table Id, Name, MainWindowTitle -AutoSize
}
 
End {}

Usage

# get all active windows
Get-Process | Where-Object { $_.MainWindowTitle } | Format-Table Id, Name, MainWindowTitle -AutoSize
 
# find specific application windows
Get-Process | Where-Object { $_.MainWindowTitle -like "*Chrome*" }

Appendix

Note created on 2024-04-19 and last modified on 2024-12-31.

See Also


(c) No Clocks, LLC | 2024