# get-shellwindows.ps1
# MSDN Sample to get help
# Thomas Lee - tfl@psp.co.uk
# First get shell object
$Shell = new-object -com Shell.Application
# Now get open windows
$windows = $Shell.windows()
# Display details
"There are {0} open windows on this system" -f $windows.count
$i=1
foreach ($window in $windows) {
"Window {0} - title={1}, path={2}" -f $i++, $window.locationname, $window.path
}
This script produces the following output on my Server 2008 workstation:
PS C:\Users\tfl>
C:\foo\get-shellwindows.ps1
There are 3 open windows on this system
Window 1 - title=Dave Edmunds - Getinge 2000 - FM, path=C:\Windows\
Window 2 - title=1982-05-07 Once Upon A Time.flac, path=C:\Windows\
Window 3 - title=template, path=C:\Windows\