首页 > 解决方案 > Azure Active Directory webhook 密码过期,向团队发送通知

问题描述

当用户 Azure AD 密码过期时,您将如何向团队发送消息?到目前为止,我正在研究在频道中使用传入的网络挂钩并编写一个 power shell 脚本来计算或读取用户当前的密码到期日期,并在他们需要更新时向他们发送个人消息。

标签: powershellazure-active-directorywebhooks

解决方案


目前,当帐户密码即将到期时,不会发送电子邮件通知,因为 O365 提供的唯一通知是任务栏的 Windows 通知区域中的弹出窗口。

您可以找到详细的 powershell 脚本,该脚本将连接到 MSOL 租户并向所有 Office 365 用户发送密码过期通知:

https://community.spiceworks.com/how_to/133073-how-to-notify-office-365-users-that-passwords-will-expire

要点是:

foreach ($user in $users)
{
$Name = $user.DisplayName
$emailaddress = $user.UserPrincipalName
$passwordSetDate = $user.LastPasswordChangeTimestamp
$expireson = $passwordsetdate + $maxPasswordAge
$today = (get-date)
$daystoexpire = (New-TimeSpan -Start $today -End $Expireson).Days

# Set Greeting based on Number of Days to Expiry.

# Check Number of Days to Expiry
$messageDays = $daystoexpire

if (($messageDays) -ge "1")
{
$messageDays = "in " + "$daystoexpire" + " days."
}
else
{
$messageDays = "TODAY."
}

您可以使用此代码并存储密码即将过期的用户,然后您可以将详细信息保存在任何数据库中。

此外,您可以使用 Webhook 实施,它将检查用户在 DB 中的条目并在 Teams 中发送通知。

希望能帮助到你。


推荐阅读