powershell - 在 PowerShell 中获取 Azure Active Directory 密码到期日期

标签 powershell azure active-directory azure-active-directory

我正在使用 Azure Active Directory,想知道用户的密码何时过期。

目前,我使用这些 PowerShell 命令成功连接到 msol 服务并获取密码到期日期,但我不太确定如何获取密码到期日期。

我正在使用 Azure Active Directory PowerShell 模块。

Connect-MsolService
    Get-MsolUser -UserPrincipalName 'Username' | Select PasswordNeverExpires

最佳答案

您正在查找 LastPasswordChangeTimestamp 属性:

Get-MsolUser -UserPrincipalName 'Username' |Select LastPasswordChangeTimestamp

这只会告诉您密码上次更改的时间,而不是密码过期的时间,因此还要从密码策略中获取密码有效性:

$PasswordPolicy = Get-MsolPasswordPolicy
$UserPrincipal  = Get-MsolUser -UserPrincipalName 'Username'

$PasswordExpirationDate = $UserPrincipal.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)

$PasswordExpirationDate 现在应该具有密码过期的时间戳

关于powershell - 在 PowerShell 中获取 Azure Active Directory 密码到期日期,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43294517/

相关文章:

c# - 如何通过 Microsoft Graph API/SDK 向 Microsoft 团队发送自适应卡?

c# - 从 Active Directory 检索用户名

powershell - 如何阻止 PowerShell SqlCommand 回显参数

powershell - 使用 Powershell 获取所有 AD 用户的递归组成员身份

powershell - 从 .ps1 脚本设置环境变量值在 Github Actions 中不起作用

powershell - 如何编写中间带有参数的 PowerShell 别名?

azure - Microsoft Azure ServiceBus - 如何进行请求/响应?

azure - 如何通过在azure数据工厂中查找sap表连接器获取最大数据?

Powershell Active Directory - 将我的 get-aduser 搜索限制到特定 OU [和子 OU]

c# - 递归地获取 Active Directory 组的成员,即包括子组