Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Does any encrypted password in a text file expire?

$
0
0

I know this sounds crazy, but I have an encrypted password in a file that works for a while then suddenly stops and I have to recreate the file.  And no, the account password itself has not changed.  Is the encrypted PW  based on some timer, for example like when the machine password in the domain changes?

Here is my code to create the file:

$SecurePassword = Read-Host -Prompt "Enter password for PowerShell account" -AsSecureString
$SecureStringAsPlainText = $SecurePassword | ConvertFrom-SecureString
$SecureStringAsPlainText | Out-File ".\PW.txt" -Encoding ASCII

I can then use the that password file (for an account I specify in another script) for weeks without problem.  Then suddenly it fails to work.  I get this error:

ConvertTo-SecureString : Key not valid for use in specified state.

I am using the same account to run the script that I used to create the PW file - so that is not the problem.  The only way to fix this is to recreate the PW file, using the same exact password I used to create it the previous time.  In other words - nothing has changed that I know of.  Same password, same account name, etc.  So I am wondering, is there something on the machine I run the script from that is used to encrypt the PW with, and that "something" changes every couple of months?

My guess is the machine domain account password changes and this breaks the encrypted PW file. Am I right?

Thanks

NK


Viewing all articles
Browse latest Browse all 21975

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>