Keeping a secret isn't easy. You can try using the technique in this link: using-saved-credentials-securely-in-powershell-scripts <== read all the caveats and other ways to keep that password a secret.
PowerShell Script issue with Plaintext Password
PerserPolis-1732
1,971
Reputation points
Hi
I have the following Script and use here the Password as Plaintext. Is there any way to set here the Password "test" as hidden? I mean nobody should seem the Password in the Script
$user = New-LocalUser -AccountNeverExpires:$true -Password ( ConvertTo-SecureString -AsPlainText -Force 'test') -Name "admin" -FullName "ADMIN RIGHT" -Description "Local Admin"
Add-LocalGroupMember -Group "Administrators" -Member $user
regards
Windows for business Windows Server User experience PowerShell
8,330 questions