Site icon RDR-IT

Active Directory: Create a user with PowerShell

This “how to” tutorial explains how to create users in Active Directory using the New-ADUser cmdlet in PowerShell

Create a user in Active Directory with PowerShell

Open a PowerShell window

On a domain controller, open a PowerShell command prompt.

Create the user using the New-ADUser cmdlet and validate the command

Example to create the user Jean DUPONT:

New-ADUser -Name "Jean DUPONT" -GivenName "Jean" -Surname "DUPONT" -SamAccountName "jdupont" -UserPrincipalName "jdupont@lab.intra" -AccountPassword (ConvertTo-SecureString -AsPlainText "Pàssw0rd" -Force) -Enable $true -ChangePasswordAtLogon $true -Path "OU=Users,OU=IT,OU=Services,DC=LAB,DC=INTRA"

Validate user creation with the Get-ADUser command

Enter the following command to display user information:

Get-ADUser -Identity "jdupont"

Paramètres de la commande New-ADUser

ParamètreDescription
-NameActive Directory object name
-GivenNameUser’s first name
-SurNameSurname
-SamAccountNameUser ID
-UserPrincipaleNameUser ID consisting of the UPN suffix (@domain.local)
-AccountPasswordUser password
-Enable The account will be activated
-ChangePasswordAtLogonForce user change at next logon
-PathLocation in the directory, if not specified the user will be created in the Users container.

Source : https://docs.microsoft.com/en-us/powershell/module/addsadministration/new-aduser?view=win10-ps

Exit mobile version