No, you don’t want to do that…

$File = "\\Machine1\SharedPath\Password.txt"
[Byte[]] $key = (1..16)
$Password = "P@ssword1" | ConvertTo-SecureString -AsPlainText -Force
$Password | ConvertFrom-SecureString -key $key | Out-File $File

secure-string and running this one time to create the password is one way of doing that. Not great but still WAY better than a plaintext password in the script.

If you post code, please use the ‘Insert Code’ button. Please and thank you!

codebutton_small.png

@davidhill1404

1 Spice up