Select Folder Dialog


posted by Tobias Weltner
12-23-2008

Downloads: 635
File size: 361 B
Views: 6,340

Embed
Select Folder Dialog
  1. function Select-Folder($message='Select a folder', $path = 0) { 
  2.     $object = New-Object -comObject Shell.Application  
  3.      
  4.     $folder = $object.BrowseForFolder(0, $message, 0, $path
  5.     if ($folder -ne $null) { 
  6.         $folder.self.Path 
  7.     
  8.  
  9. Select-Folder  
  10. Select-Folder 'Select the folder you want!' 
  11. Select-Folder -mess 'Select some folder!' -path $env:windir 

Uses the Shell.Application COM object to display a dialog that lets you select a folder. You can optionally specify a header text for your dialog and also default the dialog to any root folder you want. If the user selects a folder, the folder path is returned, otherwise $null.

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.