Occasional Contributor
embedding passwords in scripts? Is there a better way?

There are several scenarios where I need to execute a script that requires a password to an external system.  Is there a recommended best practice for doing this?


The current need is to join a windows computer to the domain, which is very common.  But, there are other scenarios where credentials are needed.


If this is covered in the documentation somewhere I missed it.  I have tried to use the powershell PSCredential object to store encrypted credentials with mixed results.


Any help would be appreciated!