Attempting a set up a powershell form that creates a new user in our AD, script works great but being that this is for contractors I need to echo the password that they input and save it to a csv that I am exporting. Below is what I have so far
New-ADUser -Name "$d" -AccountExpirationDate "$j" -AccountPassword (Read-Host AsSecureString "Enter a password below")
Secure strings aren't as secure as one might think. Read the password into a variable instead of putting Read-Host
in a subexpression:
$pw = Read-Host -AsSecureString -Prompt "Password"
New-ADUser -Name "$d" -AccountExpirationDate "$j" -AccountPassword $pw
and you can decrypt the secure string like this:
$cred = New-Object Management.Automation.PSCredential ('x', $pw)
$cred.GetNetworkCredential().Password