Converting a Password to Secure String

Windows_PowerShell_icon

I forget this every time I reset my password…

(Get-Credential).Password | ConvertFrom-SecureString | Out-File "C:\Scripts\365SecureString.txt"

Using it:

$pass = cat "C:\Scripts\365securestring.txt" | convertto-securestring
$mycred_online = new-object -typename System.Management.Automation.PSCredential -argumentlist "UserAccount@contoso.com",$pass
$mycred = new-object -typename System.Management.Automation.PSCredential -argumentlist "UserAccount",$pass