Powershell Tricks
Here are two things that I haven't found written about other places, but that are hinted at in the help for New-Object.
Open an explorer window in the current directory:
> $shell = New-Object -comObject shell.application
> $shell.Explore("$(resolve-path .)")
You can present a folder selection dialog to a user:
> $shell.BrowseForFolder(0, "Title", 0, "c:\") | get-member
TypeName: System.__ComObject#{a7ae5f64-c4d7-4d7f-9307-4d24ee54b841}
Name MemberType Definition
---- ---------- ----------
CopyHere Method void CopyHere (Variant, Variant)
DismissedWebViewBarricade Method void DismissedWebViewBarricade ()
GetDetailsOf Method string GetDetailsOf (Variant, int)
Items Method FolderItems Items ()
MoveHere Method void MoveHere (Variant, Variant)
NewFolder Method void NewFolder (string, Variant)
ParseName Method FolderItem ParseName (string)
Synchronize Method void Synchronize ()
Application Property IDispatch Application () {get}
HaveToShowWebViewBarricade Property bool HaveToShowWebViewBarricade () {get}
OfflineStatus Property int OfflineStatus () {get}
Parent Property IDispatch Parent () {get}
ParentFolder Property Folder ParentFolder () {get}
Self Property FolderItem Self () {get}
ShowWebViewBarricade Property bool ShowWebViewBarricade () {get} {set}
Title Property string Title () {get}
Use above to select something:
> $shell.BrowseForFolder(0, "Title", 0, "c:\").Self.Path
This MSDN page gives the information you need for the third argument. It is a 'flags' field that can be any combo of ulFlags on that page.
See $shell | Get-Member for more.