0

When I run a Powershell script using an encrypted password:

$PasswordEncrypted = Get-Content "C:\SecureFolder\FileWithPasswordEncrypted.txt" | ConvertTo-SecureString

I get this error:

ConvertTo-SecureString: Error occurred during a cryptographic operation.

What am I doing wrong?

1 Answer 1

2

In this particular case, I am trying to read a secured string from a file made by another user. When such a file with a password is prepared without the –Key or –SecureKey parameters of ConvertTo-SecureString, only the same user account on the same computer will be able to use this encrypted string.

Source: https://www.pdq.com/blog/secure-password-with-powershell-encrypting-credentials-part-1/#convertto-securestring-encrypting-passwords-and-other-strings

A similar topic: ConvertTo-SecureString run without key on different user account, is there a way (with proper credentials) to get this working from a different user?

Sign up to request clarification or add additional context in comments.

4 Comments

"I am trying to read a secured string from a file made by another user" sounds like something you should include in the question :)
Fyi: if you omit the Key argument for the ConvertTo-SecureString cmdlets, the encryption will be based on the Data Protection API (DPAPI). Also note that DPAPI is only available on Windows systems.
@MathiasR.Jessen, a little bit of narration ;-) But to be more serious, I didn't know about it earlier, so the story in question is for real.
@iRon, you are right! Although I sometimes use non-Windows OSes, here I forget about the Windows context. Vote up for you, guys!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.