Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Create new AD users in batches through scripts

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

The basic command line for creating an AD user is as follows:

New-Aduser-Name "Test Account1"-Surname Test-Givenname Account1-Company Contoso-Country CN-Department Test-City BJ-AccountPassword (ConvertTo-SecureString-AsPlainText "Ts12345678"-Force)-Path "OU=Users,DC=contoso,DC=com"-enabled $true-UserPrincipalname testaccount1@contoso.com

Refer to the TechNet documentation:

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

Then, set the parameters and pass in the parameter values from the Excel table:

$Users = Import-Csv-Path "C:\ Userlist-sn.csv"

Foreach ($User in $Users)

{

$Displayname = $User.Firstname + "" + $User.Lastname

$UserFirstname = $User.Firstname

$UserLastname = $User.Lastname

$UPN = $User.email

$Password = $User.Password

$depart=$User.department

New-Aduser-Name $Displayname-Surname $UserLastname-Givenname $UserFirstname-Company Contoso-Country CN-Department $depart-City BJ-AccountPassword (ConvertTo-SecureString-AsPlainText "$Password"-Force)-Path "OU=Users,OU=$depart,DC=Contoso,DC=com"-enabled $true-UserPrincipalname $UPN

}

Create a new Excel file, then run the script, and the user successfully creates it.

Script reference documentation:

Https://social.technet.microsoft.com/wiki/contents/articles/24541.powershell-bulk-create-ad-users-from-csv-file.aspx#Reference

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report