2,187
edits
m (→Store Password Securely: Added "ConvertTo-SecureString : Key not valid for use in specified state") |
(→Store Password Securely: Added "Convert SecureString To Plain Text") |
||
Line 69: | Line 69: | ||
The password file must be created/encrypted as the same logged in user as the account under which the script will run. Therefore if your script will be running from a scheduled task, run from a server using a service account, you must be logged onto the that machine with the service account when you create the file. | The password file must be created/encrypted as the same logged in user as the account under which the script will run. Therefore if your script will be running from a scheduled task, run from a server using a service account, you must be logged onto the that machine with the service account when you create the file. | ||
=== Convert SecureString To Plain Text === | |||
To decrypt a secure string use the following (this must be run from the same user session used to encrypt the string) | |||
<source lang="powershell"> | |||
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($EncryptPass) | |||
[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR) | |||
</source> | |||
== Logged-In User's Credentials == | == Logged-In User's Credentials == |