Skip to content

Instantly share code, notes, and snippets.

@sweeneyrobb
Last active December 22, 2015 17:09
Show Gist options
  • Save sweeneyrobb/6504243 to your computer and use it in GitHub Desktop.
Save sweeneyrobb/6504243 to your computer and use it in GitHub Desktop.
a cool file select powershell script I found.
function Select-FileDialog
{
param([string]$Title, [string]$Directory, [string]$Filter="All Files (*.*)|*.*" )
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
$objForm = New-Object System.Windows.Forms.OpenFileDialog
$objForm.InitialDirectory = $Directory
$objForm.Filter = $Filter
$objForm.Title = $Title
$Show = $objForm.ShowDialog()
if ($Show -eq "OK") {
Return $objForm.FileName
} else {
Write-Error "Operation cancelled by user."
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment