Similar to this question, after running the following code the browser dialog does appear with all the correct buttons, but the selection area that usally displays available folders is missing:
[void] [Reflection.Assembly]::LoadWithPartialName( 'System.Windows.Forms' )
$d = New-Object Windows.Forms.FolderBrowserDialog
$d.ShowDialog( )
I encountered this problem a while back and found the following COM workaround on the MSDN forums:
$app = new-object -com Shell.Application
$folder = $app.BrowseForFolder(0, "Select Folder", 0, "C:\")
if ($folder.Self.Path -ne "") {write-host "You selected " $folder.Self.Path}
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.dotnet.framework.windowsforms.controls&tid=3607557a-43b3-40bf-8276-be00526e0520&p=1
I believe it is a problem with PowerShell running in a MTA Thread. You can run the CTP of Version 2 in a STA (single threaded apartment) mode and it will pull up the proper folder selection. It does pull the menu up behind the shell window though.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With