Public/Read-FolderBrowserDialog.ps1

<#
.SYNOPSIS
    Show an Open Folder Dialog and return the directory selected by the user.
.DESCRIPTION
    Long description
.EXAMPLE
    $directoryPath = Read-FolderBrowserDialog -Message "Please select a directory" -InitialDirectory 'C:\' -NoNewFolderButton
    if (![string]::IsNullOrEmpty($directoryPath)) { Write-Host "You selected the directory: $directoryPath" }
    else { "You did not select a directory." }
.INPUTS
    Inputs (if any)
.OUTPUTS
    Output (if any)
.NOTES
    General notes
#>

function Read-FolderBrowserDialog() {
    param(
        [string]$Message,
        [string]$InitialDirectory,
        [switch]$NoNewFolderButton
    )
    $browseForFolderOptions = 0
    if ($NoNewFolderButton) { $browseForFolderOptions += 512 }

    $app = New-Object -ComObject Shell.Application
    $folder = $app.BrowseForFolder(0, $Message, $browseForFolderOptions, $InitialDirectory)
    if ($folder) { $selectedDirectory = $folder.Self.Path } else { $selectedDirectory = '' }
    [System.Runtime.Interopservices.Marshal]::ReleaseComObject($app) > $null
    return $selectedDirectory
}