Skip to content

Instantly share code, notes, and snippets.

@gitfvb
Last active August 23, 2018 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gitfvb/070c1cd43feb7a60a44b15834ad7efc7 to your computer and use it in GitHub Desktop.
Save gitfvb/070c1cd43feb7a60a44b15834ad7efc7 to your computer and use it in GitHub Desktop.
File Dialogue in Powershell
Add-Type -AssemblyName System.Windows.Forms
Function Get-FileName($initialDirectory, $filter)
{
$OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
$OpenFileDialog.initialDirectory = $initialDirectory
$OpenFileDialog.filter = $filter
$OpenFileDialog.ShowDialog() | Out-Null
$OpenFileDialog.filename
}
Get-FileName -initialDirectory $scriptPath -filter "CSV Files(*.CSV;*.TXT)|*.CSV;*.TXT|All files (*.*)|*.*";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment