Encrypt password (e.g. for use in PowerShell)

PS:

Defined as a function (e.g. to use in PSProfile)

function fcreds(){
$GetCredential = Get-Credential
[string]$usr = $GetCredential.username
[string]$Credfilename = $usr.split("@")[0]
$loc = "C:\TEMP\EncryptedPasswords\"
$out = $loc + $Credfilename + ".txt"
$GetCredential.Password | ConvertFrom-SecureString | Out-File $out
}