在PowerShell中获取Azure Active Directory密码的到期日期 [英] Get Azure Active Directory password expiry date in PowerShell
问题描述
我正在使用Azure Active Directory,并且想知道用户密码何时过期。
I am working with Azure Active Directory and want to know when a user's password expires.
当前,我使用这些PowerShell命令成功连接到msol服务并获取密码。有效期,但是我不太确定如何获取密码有效期。
Currently I use these PowerShell commands to connect to msol service successfully and get password expiry, but I'm not quite sure how to get password expiry date.
我正在使用Azure Active Directory PowerShell模块。
I am using Azure Active Directory PowerShell module.
Connect-MsolService
Get-MsolUser -UserPrincipalName 'Username' | Select PasswordNeverExpires
推荐答案
您正在寻找 LastPasswordChangeTimestamp
属性:
Get-MsolUser -UserPrincipalName 'Username' |Select LastPasswordChangeTimestamp
这仅告诉您密码上次更改的时间,而不是密码过期的时间,因此请从密码策略也是如此:
This only tells you when the password was last changed, not when it will expire, so grab the password validity from the Password Policy as well:
$PasswordPolicy = Get-MsolPasswordPolicy
$UserPrincipal = Get-MsolUser -UserPrincipalName 'Username'
$PasswordExpirationDate = $UserPrincipal.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)
$ PasswordExpirationDate
现在应该具有密码过期的时间戳
$PasswordExpirationDate
should now have the timestamp for when the password expires
这篇关于在PowerShell中获取Azure Active Directory密码的到期日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!