Powershell Script to list expiration dates for accounts in Active Directory 2008 or 2012.

Hello All, I am looking for a Powershell script that I can use for listing user accounts in Active Directory (2012) with any of the following criteria
1) expired account with the expiration date, or 2) active accounts that have expiration dates and (if possible) the due date for expiration.

This is an ongoing project and any assistance is deeply appreciated. Thank you in advance.
howard temproSystems AdministratorAsked:
Who is Participating?
 
oBdACommented:
That should do the trick:
Get-ADUser -Filter "(accountExpires -lt $([Int64]::MaxValue)) -and (accountExpires -gt 0)" -Property accountExpires, AccountExpirationDate -ResultSetSize $null |
	Select-Object SamAccountName, AccountExpirationDate, @{n='Expired'; e={$_.AccountExpirationDate -lt [DateTime]::Now}}, DistinguishedName |
	Export-Csv -NoTypeInformation -Path C:\Temp\AccountExpiration.csv

Open in new window

Replace the last line with this to see the results in a table instead of a csv:
	Out-GridView

Open in new window

0
 
Naveen SharmaCommented:
You can try the powrshell script to get a list of enabled Active Directory accounts and their password expiry time

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")}} 

Open in new window

For more information, please refer to the below links.

http://password-expiration-notification.blogspot.in/

https://4sysops.com/forums/topic/list-ad-accounts-with-expiration-date/
0
 
howard temproSystems AdministratorAuthor Commented:
Working on your solution now. Thank you very much for the work. I will update this post as soon as I get a test result.
0
 
howard temproSystems AdministratorAuthor Commented:
I cannot thank you all enough for the work that you posted. All of these were helpful, and I appreciate your swift responses. My problem has been resolved.
0
 
howard temproSystems AdministratorAuthor Commented:
Thank you all for your swift reply and excellent contributions. You have resolved my issue. I appreciate the work that you posted.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.