您好,登錄后才能下訂單哦!
基本的創建AD用戶的命令行,測試如下:
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
然后,設定參數,講參數值從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文件,然后運行腳本,用戶成功創建。
腳本參考文檔:
https://social.technet.microsoft.com/wiki/contents/articles/24541.powershell-bulk-create-ad-users-from-csv-file.aspx#Reference
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。