# Browse-Folder.ps1
# MSDN Sample using PowerShell
# Thomas Lee - tfl@psp.co.uk
# First get shell object
$Shell = new-object -com Shell.Application
# Now Open up a browse window
$ssfWINDOWS = 36
$objFolder=$Shell.BrowseForFolder(0, "PowerShell Sample", 0, $ssfWINDOWS)
# display the selected folder
$objFolder
# Count the number of items in the selected folder
"This folder contains {0} items" -f ($objfolder.items()).count
This sample produces the following output on my ssytem, when the C:\Windows folder is selected:
PSH [D:\foo]: .\browse-folders.ps1
Title : WINDOWS
Application : System.__ComObject
Parent :
ParentFolder : System.__ComObject
Self : System.__ComObject
OfflineStatus : -1
HaveToShowWebViewBarricade : True
ShowWebViewBarricade : True
This folder contains 193 items