Powershell script to save user credentials in a xml file
Instead of letting the user (1) choose a folder and (2) choose a file name, you can just present the user with a Save File Dialog. It also warns the user if he tries to overwrite an existing file.
If the user cancels one of your dialogs, you should cancel the script rather than continue with invalid data.




$dialog = New-Object System.Windows.Forms.SaveFileDialog
$dialog.FileName = "Credentials.xml"
$dialog.Filter = "XML files (*.xml)|*.xml|All files|*.*"

if ($dialog.ShowDialog() -ne "OK")
{
    exit
}

...

Get-Credential | Export-Clixml $dialog.FileName