$keyFile = "D:\aes.key"
$key = New-Object Byte[] 32

$key | out-file $keyFile

Read-Host "Enter Password" -AsSecureString | ConvertFrom-SecureString -key $key | Out-File "D:\pwd.txt"

$userName = "YourUserName"
$passwdFile = "D:\pwd.txt"
$keyFile = "D:\aes.key"
$key = Get-Content $keyFile
$Cred = New-Object -TypeName System.Management.Automation.PSCredential `
-ArgumentList $userName, (Get-Content $passwdFile | ConvertTo-SecureString -Key $key)