powershell - Azure Active Directory webhook 密码过期,向团队发送通知
问题描述
当用户 Azure AD 密码过期时,您将如何向团队发送消息?到目前为止,我正在研究在频道中使用传入的网络挂钩并编写一个 power shell 脚本来计算或读取用户当前的密码到期日期,并在他们需要更新时向他们发送个人消息。
解决方案
目前,当帐户密码即将到期时,不会发送电子邮件通知,因为 O365 提供的唯一通知是任务栏的 Windows 通知区域中的弹出窗口。
您可以找到详细的 powershell 脚本,该脚本将连接到 MSOL 租户并向所有 Office 365 用户发送密码过期通知:
要点是:
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 中发送通知。
希望能帮助到你。
推荐阅读
- sql - 如何订购逗号分隔的列表
- java - 如何使用 AspectJ 在 AOP 中为每个类、每个对象和每个方法/源位置部分创建一个方面
- arrays - 搜索和更新数组整数值的最佳数据结构是什么?
- reactjs - 无法模拟反应组件道具的功能
- angular - 如何在 Angular 的 pdf 查看器中播放视频?
- python - OTP 验证时 JWT 令牌不匹配
- java - 我已经设置了像这段代码这样的插页式广告获取所有时间错误代码 com.facebook.ads.AdError@e0e1b7a
- c# - ToDictionary 的 EF Core 异常
- python - 如何在 Django 中的 2 个日期之间归档数据?
- python - 有效的 HTTP 请求