How to create a new user account in Active Directory using Powershell

To create a new user account in Active Directory using PowerShell, you can use the New-ADUser cmdlet from the ActiveDirectory module.

Before you can use the New-ADUser cmdlet, you will need to import the ActiveDirectory module and connect to your Active Directory domain using the Import-Module and Connect-ADServer cmdlets.

Here is an example of how you can use the New-ADUser cmdlet to create a new user account:

Import-Module ActiveDirectory
Connect-ADServer -Server "dc01.contoso.com"

New-ADUser -Name "John Doe" -SamAccountName "jdoe" -UserPrincipalName "[email protected]" -GivenName "John" -Surname "Doe" -Enabled $true -AccountPassword (ConvertTo-SecureString "P@ssw0rd" -AsPlainText -Force) -ChangePasswordAtLogon $true

This will create a new user account with the name “John Doe”, the SAM account name “jdoe”, and the user principal name “[email protected]”. The GivenName and Surname parameters specify the first and last name of the user, and the Enabled parameter specifies that the account should be enabled. The AccountPassword parameter specifies the password for the account, and the ChangePasswordAtLogon parameter specifies that the user should be required to change their password the next time they log on.

You can also use other parameters of the New-ADUser cmdlet to specify additional details for the user account, such as the department, the title, and the manager.

For more information about the New-ADUser cmdlet and the available parameters, you can refer to the Microsoft documentation:

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

Leave a Comment