Credentials
Blah
Storing Credentials for use on remote computers
http://www.iheartpowershell.com/2012/01/generate-random-securestring-key.html
#Create random key (1..32 |% { [byte](Get-Random -Minimum 0 -Maximum 255) }) -join "," #Store Password read-host -assecurestring | convertfrom-securestring -Key $Key | out-file C:\scripts\securestring.txt
$Key = (55,198,215,78,28,29,92,101,8,164,203,133,117,153,209,244,123,100,109,9,78,29,55,250,77,193,38,34,222,157,202,241) $SecureStringPath = "C:\scripts\securestring.txt" $username = "domain\username" $password = cat $SecureStringPath | convertto-securestring -Key $Key $Cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
This is not a safe way to store a password if you have the key and the securestring you can still get the password in plain text.
$Cred.GetNetworkCredential().Password
$cred = Get-Credential; $cred | Export-Clixml C:\credential.clixml
$Credential = Import-Clixml C:\credential.clixml