Storing and using credentials

Start with writing your password into a file

read-host -assecurestring | convertfrom-securestring | out-file C:\securestring.txt 

Next use the file in a script

$userName = "FooRoo"
$passWord = cat C:\securestring.txt | convertto-securestring
$credEntial = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName,$passWord

<Command> -Credential $credEntial