karldenton Posted September 2, 2020 Posted September 2, 2020 Hi We use AD admin centre to set staff Passwords to expire every 90 days However if I run net user username /domain in powershell it says it expires in 2023 I have tried a script but it still doesn't pick any up as AD thinks they are not expiring till 2023 Does anyone have a different script we can use to see if a password has expired Thanks
fordea Posted September 2, 2020 Posted September 2, 2020 Try using the msDS-UserPasswordExpiryTimeComputed property: Get-ADUser j.bloggs -Properties msDS-UserPasswordExpiryTimeComputed | Select Name, @{n='PwdExpiry';e={[Datetime]::FromFileTime($_.'msDS-UserPasswordExpiryTimeComputed')}} 1
karldenton Posted September 2, 2020 Author Posted September 2, 2020 Amazing, that picks up the correct date. Is there a way to list all AD accounts that have expiry date of before today? Thanks
fordea Posted September 2, 2020 Posted September 2, 2020 Sure you can add a Where-Object filter to check this and also change Get-ADUser to fetch multiple (or all) of your AD users. To check every AD User you could do: Get-ADUser -Filter * -Properties msDS-UserPasswordExpiryTimeComputed | Select Name, @{n='PwdExpiry';e={[Datetime]::FromFileTime($_.'msDS-UserPasswordExpiryTimeComputed')}} | Where {[Datetime]::Now -gt $_.PwdExpiry} I'd recommend filtering Get-ADUser first to remove service accounts and the like if you only intend to check staff/pupil accounts. 1
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now