Warm tip: This article is reproduced from stackoverflow.com, please click
powershell

Powershell FolderBrowserDialog Can't select external shares

发布于 2020-03-28 23:17:46

So I have a working Windows.Forms.FolderBrowserDialog function for Folder selection in my Script.

I noticed Today that I can't any external Shares or even see them with it.

Is there another function for that or is there some special attribute I have to set to see external Shares?

Questioner
TheLinkedOne
Viewed
110
Scepticalist 2020-01-31 18:24

How do you mean "external"? It will see mapped drives and anything in the "Network" folder, though bear in mind that local network discovery could be disabled in the OS and you'd have to enable this in Windows

If you run this with a UNC folder path it should open the browser in that folder:

$RootFolder = '\\myserver\myfoldername'

$FolderBrowser = New-Object System.Windows.Forms.FolderBrowserDialog
$FolderBrowser.Description = 'Select a folder'
$FolderBrowser.ShowNewFolderButton = $false
$FolderBrowser.SelectedPath = $RootFolder
$result = $FolderBrowser.ShowDialog((New-Object System.Windows.Forms.Form -Property @{TopMost = $true }))

enter image description here