Solved

Posted on 2016-08-09
52 Views
Hi,
I am using ADFind to list my AD users. I would like to add the account expirations if possible. Here is the current script that gives me all the users with their names:

adfind -default -f "&(objectcategory=person)(objectclass=user)" samaccountname displayname -csv > c:\users.csv
Is this possible?

Thank you
0
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points
• 5
• 4

LVL 1

Expert Comment

ID: 41749681
Do you want to continue using adfind, or powershell?
0

LVL 1

Expert Comment

ID: 41749722
Use to luv me some joeware!!
adfind -default -f "&(objectcategory=person)(objectclass=user)" samaccountname displayname accountexpires -csv > c:\users.csv


You prolly can't really read it though, cause it is in MS speak....
0

Author Comment

ID: 41750159
Me love joeware too! However the dates came back as: 9.22337E+18

Thank you
0

LVL 1

Accepted Solution

SquigglyMonkey earned 500 total points
ID: 41750281
That's what I said. I don't think you can use that particular Joeware tool for that, not natively anyway.
open an elevated powershell session and try this:
import-module activedirectory
Get-AdUser -Filter * -Properties * | Select SAMAccountname, DisplayName, AccountExpirationDate | Export-CSV -Path C:\path\to\folder\file.csv

Change the path to wherever you need the exported file.
0

Author Comment

ID: 41750335
I ran the last script in the elevated powershell as directed. It returned the names but no expiration dates. The column was there but they were all blank.
0

LVL 1

Expert Comment

ID: 41750374
Are the accounts set to "not expire"? Spot check and see if an account actually has an expiration date.
0

Author Comment

ID: 41750406
Ah ha! That is it. Hey, thanks for your help. Would you want to throw in a lookup for expiring passwords?
0

LVL 1

Expert Comment

ID: 41750440
get-aduser your-user-name -properties *


This will give you all the properties for your AD account, then find the one(s) you want and add it to the command I gave you above. :)
0

Author Closing Comment

ID: 41750459
Thanks again
0

## Featured Post

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

### Suggested Solutions

Windows 10 came with  a lot of built in applications, Some organisations leave them there, some will control them using GPO's. This Article is useful for those who do not want to have any applications in their image (example:me).
The Nano Server Image Builder helps you create a custom Nano Server image and bootable USB media with the aid of a graphical interface. Based on the inputs you provide, it generates images for deployment and creates reusable PowerShell scripts that …
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …