Man*_*kar 5 powershell active-directory azure azure-active-directory
我正在使用Azure Active Directory,并且想知道用户密码何时过期。
当前,我使用这些PowerShell命令成功连接到msol服务并获得密码到期,但是我不太确定如何获取密码到期日期。
我正在使用Azure Active Directory PowerShell模块。
Connect-MsolService
Get-MsolUser -UserPrincipalName 'Username' | Select PasswordNeverExpires
Run Code Online (Sandbox Code Playgroud)
您正在寻找LastPasswordChangeTimestamp属性:
Get-MsolUser -UserPrincipalName 'Username' |Select LastPasswordChangeTimestamp
Run Code Online (Sandbox Code Playgroud)
这只会告诉您密码上次更改的时间,而不是密码过期的时间,因此还要从密码策略中获取密码有效性:
$PasswordPolicy = Get-MsolPasswordPolicy
$UserPrincipal = Get-MsolUser -UserPrincipalName 'Username'
$PasswordExpirationDate = $UserPrincipal.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod)
Run Code Online (Sandbox Code Playgroud)
$PasswordExpirationDate现在应该有密码过期的时间戳
| 归档时间: |
|
| 查看次数: |
7188 次 |
| 最近记录: |