title: Powershell to select Directory location into variable using System.Windows.Forms.SaveFileDialog
body: <p>I'm trying to get the directory location using the GUI <strong>System.Windows.Forms.SaveFileDialog</strong></p>
  <p>This is the script I have so far:</p>
  <pre><code>Add-Type -AssemblyName 'System.Windows.Forms'
  $fileDialog = New-Object System.Windows.Forms.SaveFileDialog
  $fileDialog.ShowDialog()
  Write-Host &quot;Directory selected is $($fileDialog.DirectoryName)&quot;
  </code></pre>
  <p>There is no error but the result is always empty?</p>
  <pre><code>PS C:\Windows\system32&gt;     Add-Type -AssemblyName 'System.Windows.Forms'
      $fileDialog = New-Object System.Windows.Forms.SaveFileDialog
      $fileDialog.ShowDialog()
      $fileDialog.CheckPathExists
      Write-Host &quot;Directory selected is $($fileDialog.DirectoryName)&quot;
  Cancel
  True
  Directory selected is 
  </code></pre>