I am writing a PowerShell script to automate adding systems to domain but the issue is encrypting the password. I used the steps provided in the below link but the steps works only on the system I generated the encrypted password.
https://gallery.technet.microsoft.com/scriptcenter/Encrypt-Password-and-use-dd07f253
I keep getting is error - 'convertto-string: key not valid for use in specified state"
I am using the same user account to add to the domain as I built the credentials with initially, so I believe that the computer is rejecting these credentials because the SID has changed. Please suggest what can I do.
When you use your script on other systems, they are not aware of the key that was used to encrypt the password. With the key, you can use it on different systems. You can generate your own AES key and use it with the cmdlets on different systems. You can find more details on using a key with ConvertTo-SecureString
here