我正在为之工作的公司想要在用户更改密码(目前为90天规则)时弹出屏幕,这主要是由于外部要求。
我遇到的一个障碍是系统没有电子邮件告诉我用户即将到期,我正在看几件事
过期帐户和锁定帐户的日志输出,忽略未记录在已禁用帐户系统上的帐户等。
在90天的政策中,会出现一个带有接受或拒绝窗口的t $ c的初始屏幕(当他们第一次转动PC并在登录框之前弹出时,他们会看到这一点,基本上是接受你同意读了等等等等。
我不知道如何让它作为一个脚本运行,或者有两个单独的脚本,
任何输入都非常感谢
Import-Module ActiveDirectory # Required for PowerShell 2.0 only
$a = (Get-Date).Date.AddDays(-89)
# The following line will build the variable based upon the noted criteria
$b = Get-ADUser `
-Property Name, SamAccountName, PasswordLastSet, CannotChangePassword, PasswordNeverExpires `
-Filter { (PasswordLastSet -lt $a) -and (PasswordNeverExpires -eq $false) } |
Where-Object { $_.CannotChangePassword -eq $false }
# The following line will display/export the data logging the accounts to be changed
# please note the Out-File path and change to suit your needs.
$b | Format-Table Name, PasswordLastSet, CannotChangePassword, PasswordNeverExpires -AutoSize |
Out-File -FilePath "C:\passwordchanges.txt"
# The following line will actually flag the accounts to require a password change
# (after -WhatIf is removed)
$b.SamAccountName | ForEach-Object {
Set-ADUser -Identity $_ -ChangePasswordAtLogon $true -WhatIf
}