Powershell

New-ADUser: Creating Active Directory Users With PowerShell

The cmdlet “New-ADUser” is utilized to create an Active Directory user in PowerShell. The stated cmdlet parameters can be used to set the commonly used property values. It can generate multiple types of users including the “inetOrgPerson”. Moreover, the “-OtherAttributes” parameter can be used to set the values that are not associated with it.

The following post will provide usage of the “New-ADUser” cmdlet.

New-ADUser: Creating Active Directory Users With PowerShell

As described above the stated cmdlet is responsible for creating users on local and remote computers.

Example 1: Use the “New-ADUser” Cmdlet to Create a Single User

To create a new user using the “New-ADUser” cmdlet, first, add the stated cmdlet and then specify the username which needs to be created:

New-ADUser <Username>

 
After creating the new user, the user can verify it by executing the given cmdlet:

Get-ADUser <Username>

 
Example 2: Use the “Get-ADUser” Cmdlet to Get the Properties of a Newly Created User

In this illustration, the user will get the properties of a newly created user:

Get-ADUser <Username> -Properties *

 
According to the above code:

    • First, specify the “Get-ADUser” cmdlet and specify the username.
    • After that, add the “-Properties” parameter along with the “*” wildcard.

Example 3: Use the “New-ADUser” Cmdlet to Create a User With an Imported Certificate

This demonstration can be used to create a user with imported certificates:

New-ADUser -Name "JamesBen" -Certificate (New-Object System.Security.Cryptography.X509Certificates.X509Certificate -ArgumentList "Export.cer")

 
Following the above code:

    • First, specify the “New-ADUser” cmdlet.
    • Then, write the parameter “-Name” and assign the username value.
    • Lastly, add the “-Certificate” parameter and specify the stated value.

Example 4: Use the “New-ADUser” Cmdlet to Create a User and Set Properties

To create a new user and then set properties, execute the below-provided command:

New-ADUser -Name "JamesBen" -OtherAttributes @{'title'="director";'mail'="[email protected]"}

 
According to the above code:

    • First, write the “New-ADUser” cmdlet, followed by the “-Name” parameter having the username assigned to it.
    • Then, specify the “-OtherAttributes” parameter.
    • After that, create the hash-table and specify the stated values.

Example 5: Use the “New-ADUser” Cmdlet to Create a User and Set the Password

In this illustration, the new user will be created along with the new password:

New-ADUser -Name "JamesBen" -Accountpassword (Read-Host -AsSecureString "pass123") -Enabled $true

 
According to the above-stated code:

    • First, specify the “New-ADUser” cmdlet followed by the “-Name” parameter having the username value assigned to it.
    • After that, create another parameter “-Accountpassword” and assign the mentioned value to create the password.
    • Lastly, specify the “-Enabled” parameter and assign the value “$true” to it.

Example 6: Use the “New-ADUser” Cmdlet to Create an inetOrgPerson User

To create the “inetOrgPerson” type user, the “New-ADUser” cmdlet can be used:

New-ADUser -Name "JamesBen" -Type iNetOrgPerson -Path "DC=AppNC" -Server lds.samplewebsite.com:50000

 
In the stated code above:

    • First, specify the “New-ADUser” cmdlet, along with the “-Name” parameter having the username value assigned to it.
    • Then, add another parameter “-Type” and assign the value “inetOrgPerson” to it.
    • After that, specify another parameter “-Path” and assign the mentioned value.
    • Lastly, add the “-Server” parameter and specify the stated value to it.

That’s all! We have elaborated on the creation process of an Active Directory user.

Conclusion

The “New-ADUser” cmdlet in PowerShell is used to create an Active Directory user account. It uses several parameters to create an account with customized settings. This write-up has explained the “New-ADUser” cmdlet comprehensively with the aid of several examples.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.