Hi @moriah-morgan_0490 ,
If you've created a Secure Credential (Username & Password) under Admin > Secure Credentials that's named TestCred2
then the OtterScript you presented should work. There are several challenges with getting impersonation to work Windows in general (as I'm sure you've learned as a Windows admin), so we don't recommend using it unless you have to.
In your Otter configuration, my guess is that there is a problem with environment scoping; that can get a bit tricky - I would just set it to use (Any) environment for now.
As for "Secure" part of "Secure Credentials" - the password fields are stored as encrypted data, and you can only decrypt them with the Encryption Key (stored separately). They're also held in memory as securely as possible, and are "handed" to PowerShell as a PSCredential object.
The "Allow encrypted properties to be accessed" prevents OtterScript from exposing the passwords using the $CredentialProperty()
function. For example, this would cause an error unless that was checked:
Log-Information $CredentialProperty(TestCred2, Password);
However, PowerShell has no such restriction surrounding credentials. For example, you can always just do this:
$credtest = Get-Credential
Write-Host $credtest.GetNetworkCredential().Password
Microsoft's recommended way to handle this is to use Windows Authentication.
Our recommendation is to generally avoid passing important credentials to scripts (API keys, etc. seem fine)... but if you must, use a change process to ensure that you aren't running scripts that dump passwords like that.
Hope that helps,
Alana