Question:
I want to get a report of all open explorer windows titles and current paths. The current paths part of this is problem is answered here with C#, but I want this for powershell and am not sure how to adapt it.
I am not sure how to bring out the window titles part of it.
Could someone please assist.
Answer:
Sounds to me like you’re looking for something like this:
1 2 3 |
$app = New-Object -COM 'Shell.Application' $app.Windows() | Select-Object LocationURL |
AFAICS the window objects don’t have a title property, but you can get that information from
Get-Process
via the window handle ID:
1 2 3 4 5 6 7 8 9 10 |
function Get-WindowTitle($handle) { Get-Process | Where-Object { $_.MainWindowHandle -eq $handle } | Select-Object -Expand MainWindowTitle } $app = New-Object -COM 'Shell.Application' $app.Windows() | Select-Object LocationURL, @{n='Title';e={Get-WindowTitle $_.HWND}} |