Use this script to store credentials as a secure string in the local user registry. The logged in user can decipher the credentials in their own store, so it's not bulletproof, but it can be used to enable some level of automation without storing passwords in a standard text file or embedded in the script.
For information on how to use it, see the blog post at https://undocumented-features.com/2015/10/01/storing-powershell-credentials-in-the-local-user-registry/.