本文介绍了PowerShell的:密码必须更改下次登录时密码过期1天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
可能有人帮我修改如下:我需要一个的PowerShell 脚本搜索特定的组织单元有很多的用户和组:密码必须改变@下次登录时,如果密码1天之内。
到期我已经有以下脚本:
$ maxPwdAge =(GET-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days $1天=(获取最新).AddDays(1- $ maxPwdAge).ToShortDateString() 获取-ADUser便有-filter {启用当量$真-and PasswordNeverExpires当量$假-and PasswordLastSet -gt 0} -Properties * |其中{($ _ PasswordLastSet).ToShortDateString()当量$1天} |选择 *解决方案
您应该改为比较的DateTime 的物品直接,你平淡不需要 ToShortDateString()转换为在PowerShell中比较日期。同样在 SELECT * 是多余的,只能败坏对象的返回类型。
$1天=(获取最新).AddDays(1- $ maxPwdAge) 获取-ADUser便有-filter {启用当量$真-and PasswordNeverExpires当量$假-and PasswordLastSet -gt 0} -Properties * | 其中{$ _。PasswordLastSet -ge $1天}
应该做的。
Could someone help me with the following: I need a PowerShell script that searches a specific Organization Unit with a lot of users and sets: Password must change @ next logon if the password expires within 1 day.
I already have the following script:
$maxPwdAge=(Get-ADDefaultDomainPasswordPolicy).MaxPasswordAge.Days $1day=(get-date).AddDays(1-$maxPwdAge).ToShortDateString() Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False -and PasswordLastSet -gt 0} –Properties * | where {($_.PasswordLastSet).ToShortDateString() -eq $1day} | select *解决方案
You should instead compare DateTime objects directly, you plain don't need ToShortDateString() conversion to compare dates in Powershell. Also last select * is superfluous and only spoils the return type of an object.
$1day=(get-date).AddDays(1-$maxPwdAge) Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False -and PasswordLastSet -gt 0} –Properties * | where {$_.PasswordLastSet -ge $1day}Should do.
更多推荐
PowerShell的:密码必须更改下次登录时密码过期1天
发布评论