您的位置:首页 > 运维架构 > Shell

Powershell变更AD用户的属性

2017-06-02 08:25 246 查看
需求:将指定OU的用户属性中“下次登陆时更改密码”启用。该选项启用后用户的密码即过期。
#Subject: Get the passwordexpired Property of the users and Set ChangePasswordAtLogon to yes.
#Date:2017/05/26
Import-Module ActiveDirectory
# 0 is Disable ChangePasswordAtLogon
# 1 is Enable ChangePasswordAtLogon

$Myou="OU=testou,OU=MY_USER,OU=Beijing,DC=CCTV,DC=China"

Get-ADUser -SearchBase "$Myou" -Filter *  -Properties * | select Name,PasswordExpired,sAMAccountName | ForEach-Object { Set-ADUser  -identity $_.sAMAccountName -ChangePasswordAtLogon 1 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息