您好,登錄后才能下訂單哦!
基本的創(chuàng)建AD用戶的命令行,測(cè)試如下:
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
參考TechNet文檔:
https://docs.microsoft.com/en-us/powershell/module/addsadministration/new-aduser?view=win10-ps
然后,設(shè)定參數(shù),講參數(shù)值從Excel表格傳入:
$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????????????????
}
新建Excel文件,然后運(yùn)行腳本,用戶成功創(chuàng)建。
腳本參考文檔:
https://social.technet.microsoft.com/wiki/contents/articles/24541.powershell-bulk-create-ad-users-from-csv-file.aspx#Reference
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。