1.按如下格式创建 csv文件,并放在C:\test.csv路径
SamAccountName | Surname | GivenName | Name | UserPrincipalName | EmailAddress | EmployeeID | Office | Company | DisplayName | Path | Title | Department | HomePhone | StreetAddress | City | State | AccountPassword |
tan11 | 谭 | 11 | 谭11(tan11) | tan11@tan.com | tan11@tan.com | 2101363 | 东公司 | 东司 | 谭11(tan11) | OU=Account,OU=tan,DC=tan,DC=com | 东莞1号 | 东莞市 | 广东省 | Aa123456&*() |
powershell_ise.exe
Import-Csv 'C:\test.csv' | ForEach-Object { New-ADUser -SamAccountName $_.SamAccountName -Surname $_.Surname -GivenName $_.GivenName -Name $_.Name -UserPrincipalName $_.UserPrincipalName -EmailAddress $_.EmailAddress -EmployeeID $_.EmployeeID -Office $_.Office -Company $_.Company -DisplayName $_.DisplayName -Path $_.Path -Title $_.Title -Department $_.Department -HomePhone $_.HomePhone -StreetAddress $_.StreetAddress -City $_.City -State $_.State -AccountPassword(ConvertTo-SecureString -AsPlainText $_.AccountPassword -Force) -Enabled 1 -PasswordNeverExpires 0 -ChangePasswordAtLogon 0 }
注:上面执行后,需要解锁账号
Get-ADUser -Filter * -Properties * -SearchBase "dc=uxin,dc=youxinpai,dc=com"| ? {$_.lockedout -eq "true"} |unlock-adaccount
批量修改用户下次登录时须更改密码
dsquery user "OU=Account,OU=china,dc=chian,dc=com" -limit 0 | dsmod user -mustchpwd no
批量修改用户是否禁用
dsquery user "dc=cotosol,dc=com" -limit 0 | dsmod user -disabled no
dsquery user "OU=Korean,OU=Account,OU=china,DC=china,DC=com" -limit 0 | dsmod user -mustchpwd no
只显示指定级OU用户:-scope
dsquery user ou=Account,ou=china,dc=china,dc=com -scope onelevel -limit 0 | dsmod user -mustchpwd no