PS C:\Users\Administrator> ConvertTo-SecureString -key $key -String $password
ConvertTo-SecureString : Padding is invalid and cannot be removed.
At line:1 char:1
Looks like something changed in Get-Random between those PS versions. Since you’re essentially hard-coding your key either way, it would probably be safer just to save it that way, and avoid the problem.
On a side note, this doesn’t really add any security, since anyone can retrieve your key using the same PowerShell commands. I did a talk on this subject at the PowerShell summit which might interest you: Keeping Secrets - YouTube
Thank you… i’ve already seen your talk on crypto and it had helped me a lot , this is the type 1 , the script executes and it gets deleted and it happens even before the server is ready.
for now, i’ve hard-coded the working key… waiting to know what has changed in get-random even though there is a work around …