December 26th, 2015

PowerTip: Display Titles of Windows

Doctor Scripto
Scripter

Summary: Boe Prox shows how to use Windows PowerShell to find the titles of windows.

Hey, Scripting Guy! Question How can I use Windows PowerShell to find the titles of windows?

Hey, Scripting Guy! Answer Use Get-Process and display the title of the processes for windows by looking at
           the MainWindowTitle property, for example:

Get-Process | Where {

    $_.MainWindowTitle

} |

Select-Object ProcessName, MainWindowTitle

 

ProcessName          MainWindowTitle                                             

———–                     —————                                             

ApplicationFrameHost People                                                      

chrome               Browse by Tags – Hey, Scripting Guy! Blog – Site Home – Te…

mstsc                Remote Desktop Connection                                   

notepad              Untitled – Notepad                                          

PeopleApp            People                                                      

powershell           [x64] | BOE-PC\boepr on BOE-PC | PowerShell GC Memory: 25….

powershell_ise       Windows PowerShell ISE                                      

SnagitEditor         Snagit Editor – [Dec 20, 2015 4:55:14 PM]                   

WinStore.Mobile      Store                                                       

WINWORD              Manage Window Placement using Pinvoke.docx [Compatibility …

Author

The "Scripting Guys" is a historical title passed from scripter to scripter. The current revision has morphed into our good friend Doctor Scripto who has been with us since the very beginning.

1 comment

Discussion is closed. Login to edit/delete existing comments.

  • Edwin

    ok so im trying to use this code here
    #====================================
    $XN = Get-Process -Name “xnview” | Where-Object {$_.mainWindowTitle} | Select-Object MainWindowTitle
    write-host [$XN]
    #====================================
    to show the window name but it outputs
    #====================================
    [@{MainWindowTitle=Desired Window}]
    #====================================
    my question is is there a way to get it to display only the part after the = so it looks like
    #====================================
    [Desired Window]
    #====================================
    any help would be appreciated