Batch new ad user by script

Source: Internet
Author: User

The basic command line for creating AD users is tested 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 [email protected]

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

Then, set the parameters to tell the parameter values to be passed in from the Excel table:

$Users? =? Import-csv?-path? " C:\Userlist-sn.csv "????????????
Foreach? ($User? $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, and then run the script that the user created successfully.

Script reference Documentation:
https://social.technet.microsoft.com/wiki/contents/articles/24541. Powershell-bulk-create-ad-users-from-csv-file.aspx#reference

Batch new ad user by script

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.