PowerShell Script issue with Plaintext Password

PerserPolis-1732 1,971 Reputation points
2022-11-08T06:12:45.373+00:00

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
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Rich Matheisen 47,901 Reputation points
    2022-11-08T19:16:42.443+00:00

    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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.