1.新增用户脚本
Import-Csv 'C:\NewAccount\AddADUserExpirationDate.csv' | ForEach-Object {New-ADUser -SamAccountName $_.SamAccountName -Mobile $_.Mobile -employeeID $_.employeeID -title $_.Title -emailaddress $_.Mail -Name $_.Name -UserPrincipalName $_.UserPrincipalName -DisplayName $_.DisplayName -Path $_.Path -description $_.description -AccountExpirationDate $_.AccountExpirationDate -AccountPassword(ConvertTo-SecureString -AsPlainText $_.AccountPassword -Force) -Enabled 1 -ChangePasswordAtLogon 0 -PasswordNeverExpires $true}
2.excel录入用户信息
注:格式为csv
employeeID | Title | SamAccountName | Name | Password | Mobile | AccountPassword | Path | DisplayName | UserPrincipalName | description | AccountExpirationDate | |
A1234 | 产品经理 | zhangsan | 张三 | Jc605845 | zhangsan@qq.com | 12345678901 | Gg5+687641f438423 | OU=北京,OU=华为部,OU=XXX,DC=XXX,DC=com | 张三 (北京/华为部) | zhangsan@qq.com | 备注 | 2021/03/03 |