Advertisement
tankcr

Get-FileName

Jul 27th, 2017
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.     This Function creates a dialogue to return a File
  3. #>
  4.  
  5. function Get-FileName($initialDirectory)
  6. {
  7.     [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null
  8.     $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
  9.     $OpenFileDialog.initialDirectory = $initialDirectory
  10.     $OpenFileDialog.FileName = "Select User List Input File"
  11.     #can be set to filter file types
  12.     param([switch] $filtercsv)
  13.     if($filtercsv){$OpenFileDialog.filter = "CSV (*.csv)| *.csv"}
  14.     $OpenFileDialog.ShowDialog() | Out-Null
  15.     Return $OpenFileDialog.FileName
  16. }
  17.  
  18. Export-ModuleMember -Function 'Get-*'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement