学习自:
徐鹏老师的 AD Powershell 系列视频课程
创建一个启用的用户:
必要属性:
Name
SamAccountName
UserPrincipalName
DisplayName
Path
AccountPassword
New-ADUser -SamAccountName test01 -Name test01 -UserPrincipalName test01@satid.com -DisplayName "test 01" -Path "ou=Lab,dc=satid,dc=com" -AccountPassword (ConverTo-SecureString "Abc@123" -AsPlainTest -Force) -Enabled $true

批量创建10个用户
for{$i;$i -le 10;i++}
{
$user="user"+$i
$upn=$user+"@satid.com"
New-ADUser -SamAccountName $user -Name $user -UserPrincipalName $upn -DisplayName $user -Path "ou=Lab,dc=satid,dc=com" -AccountPassword (ConverTo-SecureString "Abc@123" -AsPlainTest -Force) -Enabled $true
}
