locked
Powershell: Script won't open explorer window to browse for .csv file. RRS feed

  • Question

  • Can anyone help me to figure out why the browser window won't pop up and allow me to browse to my .csv file?  

    I'm using "Windows Azure Active Directory Module for Windows Powershell".  

    I'm using Windows 7.  I've tried on my corporate laptop and my personal laptop and no luck on either.

    I pasted the code below and it seems to be correct my my view, but i am a Novice in powershell and scripting.  I'm just trying to fill in for a vacant role.  Any help is appreciated. 

     CODE BELOW * CODE BELOW  * CODE BELOW  * CODE BELOW  * CODE BELOW *

    # Exchange Online Connection Warning
    write-host -ForegroundColor Green "Make sure that you have connected to Exchange Online before running this script."
    pause 'Press any key to continue to choose a file and continue...'

    Add-Type -AssemblyName System.Windows.Forms

    $fd = New-Object system.windows.forms.openfiledialog
    $fd.InitialDirectory = '%'
    $fd.MultiSelect = $false
    $fd.showdialog()
    $path = $fd.filename

    $users = import-csv -Path $path -Delimiter "|"


    • Edited by donpark1 Monday, May 4, 2015 12:42 PM
    Monday, May 4, 2015 12:40 PM

Answers

  • I've minimized all windows (one by one) and I still don't see a dialog box.

    I've tried this on a machine that doesn't have WMF4 installed (but is up to date on .NET) and I still can't get it to launch.


    Don't retire TechNet! - (Don't give up yet - 13,225+ strong and growing)

    Weird, this works in STA not in MTA - In PSV2  By default ISE is STA and Console is MTA

    so we can try like this to see the dialog window

    powershell.exe -sta -File C:\Users\ChenV\Desktop\ShowDialog.ps1


    Regards Chen V [MCTS SharePoint 2010]



    • Proposed as answer by Mike Laughlin Monday, May 4, 2015 3:42 PM
    • Edited by Chen VMVP Monday, May 4, 2015 3:43 PM
    • Marked as answer by Boe ProxMVP Sunday, July 26, 2015 3:31 AM
    Monday, May 4, 2015 3:37 PM

All replies