powershell - ConvertTo-SecureString: Error occurred during a cryptographic operation - Stack Overflow

admin2025-04-25  3

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?

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?

Share Improve this question asked Jan 16 at 13:33 Gerard JaryczewskiGerard Jaryczewski 1,12214 silver badges25 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 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?

转载请注明原文地址:http://anycun.com/QandA/1745529765a90818.html