码迷,mamicode.com
首页 > 系统相关 > 详细

Powershell变更AD用户的属性

时间:2017-06-02 17:31:40      阅读:314      评论:0      收藏:0      [点我收藏+]

标签:identity   更改密码   china   用户   


需求:将指定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 }


本文出自 “工作备忘录” 博客,请务必保留此出处http://michael2017.blog.51cto.com/151632/1931524

Powershell变更AD用户的属性

标签:identity   更改密码   china   用户   

原文地址:http://michael2017.blog.51cto.com/151632/1931524

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!