function getcredentials {
    param(
      [Parameter(Mandatory)]
      [String] $title,
      [Parameter(Mandatory)]
      [String] $message,
      [Parameter(Mandatory=$false)]
      [String] $domain,
      [Switch] $persistent
    )
      
     if (-not $domain) { $domain = "" }
		    $credential = $host.ui.PromptForCredential($title, $message, "", $domain)
      if ($persistent.IsPresent) {
        $path = ($pwd.Path+"\cred.xml")
        $credential | Export-Clixml -Path $path
        return ("Credentials file: " + $path)
      }
      $passConvert = [Runtime.InteropServices.Marshal]::SecureStringToBSTR($credential.Password);
      $noSecurePass = [Runtime.InteropServices.Marshal]::PtrToStringBSTR($passConvert);
      return ("User: " + $credential.UserName + " - Password: " + $noSecurePass)
    # To Import
    # $credential = Import-Clixml -Path ($pwd.Path+"\cred.xml")
}