FN-GM Posted April 17, 2023 Posted April 17, 2023 Hello, It must be the lack of sleep, but I am struggling to find what I am looking for! I am looking for a Powershell command to list AD accounts that are both Enabled Beyond the account expiry date (note not the password expiry) Can anyone assist plase? Thanks
jthompson Posted April 17, 2023 Posted April 17, 2023 (edited) Get-ADUser -Filter {Enabled -eq $true} -properties AccountExpirationDate | Where-Object{$_.AccountExpirationDate -lt (Get-Date) -and $_.AccountExpirationDate -ne $null} | select-object SamAccountName, AccountExpirationDate N.b. that might be totally suboptimal, but I believe it will work. Edited April 17, 2023 by jthompson 1
FN-GM Posted April 18, 2023 Author Posted April 18, 2023 Get-ADUser -Filter {Enabled -eq $true} -properties AccountExpirationDate | Where-Object{$_.AccountExpirationDate -lt (Get-Date) -and $_.AccountExpirationDate -ne $null} | select-object SamAccountName, AccountExpirationDate N.b. that might be totally suboptimal, but I believe it will work. Thanks to a server failure I ran out of time to check properly. But I quickly ran this and it does the trick. Thanks very much!
FN-GM Posted April 20, 2023 Author Posted April 20, 2023 @jthompson thanks for this. It works a treat!
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