How to Add Users With Windows PowerShell in Server 2016

line5

In this tutorial basic PowerShell is used to create Active Directory users in Windows Server 2016

PS C:\> New-ADUser -Name “Jake Lawrence” -GivenName Mike -Surname Lawrence -SamAccountName Mike -UserPrincipalName Mike@teche.lk

2016 AA AD-2017-04-24-17-51-22.png

2016 AA AD-2017-04-24-17-55-56

2016 AA AD-2017-04-24-18-06-54

watermark 2016-aa-ad-2017-04-24-18-12-30

Provide a password for the account

-AccountPassword (Read-Host -AsSecureString “AccountPassword”)

2016 AA AD-2017-04-24-18-24-07.png

Specify a path

-Path ‘OU=Company,DC=teche,DC=lk’

To enable the user account

-PassThru | Enable-ADAccount

To add bulk users

PS C:\> Import-Csv C:\users.csv | New-ADUser -PassThru | `

Set-ADAccountPassword -Reset `

-NewPassword (ConvertTo-SecureString -AsPlainText ‘Pa$$w0rd’ -Force) `

-PassThru | Enable-ADAccount

Create a .csv file with following format (MS Excel application is used)

Name,GivenName,Surname,SamAccountName,UserPrincipalName
kamal Deshapriya,kamal,Deshapriya,kamal,Kamal@teche.lk

csv file.png

watermark 2016-aa-ad-2017-04-24-18-51-24.png

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s