Jump to content

Recommended Posts

Posted

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

 

  1. Enabled
  2. Beyond the account expiry date (note not the password expiry)

 

Can anyone assist plase?

 

Thanks

 

AccountExpires.jpg

Posted (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 by jthompson
  • Thanks 1
Posted
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!

  • 11 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...