PowerShell: create a new Active Directory user with password as a secure string

Solution 1:

Your syntax is wrong. Take a look at New-ADuser help page from Microsoft and this one from SS64. Also if you have spaces in your string (example: John Doe) you should single quote it.

It should have a syntax similar to this:

New-ADUser [-Name] <string> [-AccountExpirationDate <System.Nullable[System.DateTime]>]...

You might want to do this instead:

$secpasswd = ConvertTo-SecureString -String "pa$$word1" -AsPlainText -Force
New-ADuser -Name 'johnd' -GivenName'John' -Surname 'Doe' -DisplayName 'John Doe' -AccountPassword $secpasswd