嗨,我有以下脚本,它通过电子邮件向密码将在 $daysleftonpwd 中过期的用户发送电子邮件,但不确定如何添加“仅当用户的密码设置为过期”这意味着我不想通过电子邮件向密码已设置的用户发送电子邮件下次到期。
Get-QADGroupMember -Identity TEAM_GROUP | % {
$name = $_.Name
$email = $_.Email
$daysleftonpwd = ((Get-QADUser -SizeLimit 0 -SearchRoot $OU -Identity $_.SamAccountName | select PasswordExpires).PasswordExpires - $date | select Days).Days
if (((Get-QADUser -Identity $_.SamAccountName | select PasswordExpires).PasswordExpires - $date).Days -lt $threshold){
Write-Host "$Name would be emailed using $email because password is less than $threshold"
$y = $y + "<br>$name</br>"
mailuser
}
有任何想法吗?