Link to home
Start Free TrialLog in
Avatar of Christian Hans
Christian HansFlag for United States of America

asked on

AD User Passwords expiring in X days?

I know this seems like a dumb question... using PowerShell, how can I list and export all AD (not Azure AD) User accounts with passwords set to expire in the next 7 days?

I have tried a variation of the following, but I am just looking to export only those users that are set to expire in 7 days. Not every user and every password expiration date.

Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |

Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}


Net user SAMACCOUNTNAME /domain  also gives great info such as User name, Full Name, Password last set, Password expires, and Last logon information, but is there a way to export the info targeting just those expiring in 7 days?

Thanks in advance. 
Avatar of Hello There
Hello There

There is an MS Gallery script for this.

Active Directory User Password will expire in 7 days

https://gallery.technet.microsoft.com/scriptcenter/Active-Directory-User-49767d5e
ASKER CERTIFIED SOLUTION
Avatar of oBdA
oBdA

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Christian Hans

ASKER

Awesome, let me give that a try...

@HelloThere RE:

There is an MS Gallery script for this.
Active Directory User Password will expire in 7 days
https://gallery.technet.microsoft.com/scriptcenter/Active-Directory-User-49767d5e

I did try that, but that really didn't produce anything for me... is that because its not pulling the actual password expiration but the AD Account expiration itself (not the password)?


@oBdA - BINGO! That works for me, thank you so much.