标签: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 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文件,然后运行脚本,用户成功创建。
标签:imp splay shel dmi display word article for 用户
原文地址:http://blog.51cto.com/11128499/2299198