79508666

Date: 2025-03-14 09:51:56
Score: 1.5
Natty:
Report link

So the only way you can a create a secure string that can be used on multiple machines is to use a key when you create the password.

On the first machine run the following to make the secure string

$Key = (3,4,2,3,56,34,254,192,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)

read-host -assecurestring | convertfrom-securestring -key $Key | out-file C:\Scripts\test\securestring_movable.txt

type in the password at the prompt

then copy the secure string file onto a another machine and run

$Key = (3,4,2,3,56,34,254,192,1,1,2,23,42,54,33,233,1,34,2,7,6,5,35,43)

$password = cat C:\Scripts\test\securestring_movable.txt | ConvertTo-SecureString -Key $Key

In my use case only the secure string file lives on the remote machine. I then use Zoho's Desktop Central or Heimdal to run the script remotely. That way the key and the secure string are not on the same machine.

Reasons:
  • Long answer (-0.5):
  • No code block (0.5):
  • Unregistered user (0.5):
  • Low reputation (1):
Posted by: Alex