ad域控中批量更改密码

步骤1
Import-Module activedirectory

步骤2
get-aduser -SearchBase "ou=user,dc=contoso,dc=com" -filter *|Select-Object name,samaccountname| Export-Csv -Path c:\user.csv -Encoding utf8 -NoTypeInformation

步骤3、在导出的user.csv表格中新加password列,并为每个用户设置新密码,然后导入csv表格

import-csv -path c:\user.csv |%{Set-ADAccountPassword -identity $.samaccountname -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $.password -Force)}

也可以

import-csv -path c:\user.csv |%{get-aduser -identity $.samaccountname |Set-ADAccountPassword -Reset -NewPassword (ConvertTo-SecureString -AsPlainText $.password -Force)}