• Comments 6

I do this so frequently that I finally put it into a script called Get-WindowTitle.ps1 .

Get-Process |where {$_.mainWindowTItle} |format-table id,name,mainwindowtitle –AutoSize

Here is what it does:

[4696:0]PS> Get-WindowTitle

  Id Name              MainWindowTitle
  -- ----              ---------------
2448 mmc               Server Manager
4696 powershell        Administrator: Windows PowerShell
3828 powershell_ise    Administrator: C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe
4116 WindowsLiveWriter Get-VisibleProcess.ps1 - Windows Live Writer


Jeffrey Snover [MSFT]
Distinguished Engineer
Visit the Windows PowerShell Team blog at:
Visit the Windows PowerShell ScriptCenter at:

Leave a Comment
  • Please add 5 and 1 and type the answer here:
  • Post
  • Really, really useful.

    Thank you for this.

  • Very nice, I just put this in my $PROFILE instead and called it

    $getproc=Get-Process |where {$_.mainWindowTItle} |format-table id,name,mainwindowtitle –AutoSize

    I guess I could call that .ps1 each time my profile loads, but I figured I don't mind typing $getproc when I need to run this :)

    Thank you!  

  • Very nice script.  Jeffrey, is there a way to see a complete list of scripts submitted by the PowerShell team?  The search box does not work very well.

  • MikeW, I got back quite a few scripts by seaching all blogs with the search term ".ps1"

  • Love the idea, but when I try to use it with a -MATCH filter, it fails. Tried multiple types of syntax with -MATCH nothing has worked yet.

    Get-Process "zoom" | Where-Object {$_.mainWindowTitle -match "*ID*"} |format-table id,name,mainwindowtitle –AutoSize

    Bad argument to operator '-match': parsing "*ID*" - Quantifier {x,y} following nothing..

    At line:1 char:61

    + Get-Process "zoom" | Where-Object {$_.mainWindowTitle -match <<<<  "*ID*"} |format-table id,name,mainwindowtitle –AutoSize

       + CategoryInfo          : InvalidOperation: (:) [], RuntimeException

       + FullyQualifiedErrorId : BadOperatorArgument


    -match is for RegEx. So * becomes a quantifier and thus your search fails. Try -like instead.

    Get-Process "zoom" | Where-Object {$_.MainWindowTitle -like "*ID*"} | Format-Table Id,Name,MainWindowTitle -AutoSize

Page 1 of 1 (6 items)