Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 91
  • Last Modified:

AD Users With Expiration

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
daskas27
Asked:
daskas27
  • 5
  • 4
1 Solution
 
SquigglyMonkeyCommented:
Do you want to continue using adfind, or powershell?
0
 
SquigglyMonkeyCommented:
Use to luv me some joeware!!
adfind -default -f "&(objectcategory=person)(objectclass=user)" samaccountname displayname accountexpires -csv > c:\users.csv

Open in new window


You prolly can't really read it though, cause it is in MS speak....
0
 
daskas27Author Commented:
Me love joeware too! However the dates came back as: 9.22337E+18

Thank you
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
SquigglyMonkeyCommented:
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

Open in new window

Change the path to wherever you need the exported file.
0
 
daskas27Author Commented:
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
 
SquigglyMonkeyCommented:
Are the accounts set to "not expire"? Spot check and see if an account actually has an expiration date.
0
 
daskas27Author Commented:
Ah ha! That is it. Hey, thanks for your help. Would you want to throw in a lookup for expiring passwords?
0
 
SquigglyMonkeyCommented:
How about this,
get-aduser your-user-name -properties *

Open in new window


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
 
daskas27Author Commented:
Thanks again
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

  • 5
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now