Password expired

Louai Al Obaidi 20 Reputation points
2023-04-18T11:01:25.2933333+00:00

Hi How can i get a list (via powershell command)of expired users password in AD like this screenshot. Thanks User's image

Active Directory
Active Directory
A set of directory-based technologies included in Windows Server.
5,966 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,401 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,134 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,778 questions
{count} votes

1 answer

Sort by: Most helpful
  1. 2023-04-18T14:59:18.4733333+00:00

    Hello @Louai Al Obaidi , this PowerShell Script will calculate the password expiration date for users whose password expire. It requires the MSOnline PowerShell module:

    Connect-MsolService
    $PasswordPolicy = Get-MsolPasswordPolicy -DomainName # required
    $Users = Get-MsolUser
    $Users | 
    Where-Object { $_.PasswordNeverExpires -EQ $false-or $_.PasswordNeverExpires -eq $null } |
    ForEach-Object { $ExpiryDate = $_.LastPasswordChangeTimestamp.AddDays($PasswordPolicy.ValidityPeriod); $_ } |
    Select-Object DisplayName, userPrincipalName, `
    @{Name = "ExpiryDate"; E = { $ExpiryDate } }, `
    @{Name = "DaysToExpire"; E = { if ($ExpiryDate -gt (Get-date)) { ($ExpiryDate - (Get-date)).days } else { "Expired" } } }
    

    Let us know if you need additional assistance. If the answer was helpful, please accept it and rate it so that others facing a similar issue can easily find a solution.

    0 comments No comments