標籤:imp splay shel dmi display word article for 使用者
基本的建立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 [email protected]
參考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
通過指令碼批量建立AD使用者