Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Powershell Secure password to work on any machine

I need to write a powershell script that i can run on any machine to connect to a server. Does the secure-string encrypt using the machine or user i.e will a secure password work on any machine in the domain or can it only be decrypted on the machine it was created on. If it is the latter is there away to encrypt the password so i can run the script on any machine

like image 598
user1221996 Avatar asked Mar 22 '13 21:03

user1221996


1 Answers

To work on other machines you'll need to create a key for use with the ConvertTo-SecureString and ConvertFrom-SecureString cmdlets.

PS C:\> $Key = (3,4,2,3,56,34,254,222,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)
PS C:\>$StandardString = ConvertFrom-SecureString  $SecureString -Key $Key

http://www.leeholmes.com/blog/2006/06/01/securestrings-in-powershell/

By default, the SecureString cmlets use Windows’ Data Protection API when they convert your SecureString to and from a plain text representation. The encryption key is based on your Windows logon credentials so only you can decrypt the data that you’ve encrypted. If you want the exported data to work on another system or separate user account, you can use the parameter sets that let you provide an explicit key.

like image 121
Andy Arismendi Avatar answered Sep 21 '22 16:09

Andy Arismendi