Solved

Create AD Query for User name and User Creation Date

Posted on 2013-01-21
8
590 Views
Last Modified: 2013-01-23
I am looking for an AD Query to List all Users and their creation dates.  I need to export this to a CSV file to make a spreadsheet.
0
Comment
Question by:Twhite0909
  • 4
  • 4
8 Comments
 
LVL 5

Expert Comment

by:coraxal
Comment Utility
If you dont mind using Quest Powershell, then you can do something like this:

http://www.quest.com/powershell/activeroles-server.aspx

Get-QADUser -SearchRoot "dc=mydomain,dc=com" `
	-DontUseDefaultIncludedProperties `
	-IncludedProperties DN,SamAccountName,Name,whenCreated `
	-SizeLimit 0 | 
	Select-Object SamAccountName,whenCreated |
	Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation

Open in new window

0
 

Author Comment

by:Twhite0909
Comment Utility
So are we saying there is not an AD query to run and only PowerShell can achieve what Im looking for>?
0
 
LVL 5

Expert Comment

by:coraxal
Comment Utility
No, I'm not saying that at all...Powershell is only one way to get you there...I'm sure there are other tools perhaps built-in ones. I only offered Powershell as a possible solution since that's what I'm familiar with. Maybe others can suggest other alternatives
0
 

Author Comment

by:Twhite0909
Comment Utility
Im not that good with Powershell.  On my DC there is a Active Directory Module for Powershell. I launched that.  My domain is called AD.LOCAL so is this the right command:


Get-ADUser -SearchRoot "dc=ad,dc=local" `
      -DontUseDefaultIncludedProperties `
      -IncludedProperties DN,SamAccountName,Name,whenCreated `
      -SizeLimit 0 |
      Select-Object SamAccountName,whenCreated |
      Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
0
Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

 
LVL 5

Expert Comment

by:coraxal
Comment Utility
Try this

Get-ADUser -Properties * -SearchBase "DC=mydomain,DC=com" | 
        Select-Object SamAccountName,whenCreated |             
        Export-Csv "C:\myscripts\ADusers.csv" -NoTypeInformation

Open in new window

0
 

Author Comment

by:Twhite0909
Comment Utility
That command asks for an entry for Filter.  I hit Admin and it erroed:

PS C:\Users\WhiteT> Get-ADUser -SearchRoot "dc=ad,dc=local" `
>>       -DontUseDefaultIncludedProperties `
>>       -IncludedProperties DN,SamAccountName,Name,whenCreated `
>>       -SizeLimit 0 |
>>       Select-Object SamAccountName,whenCreated |
>>       Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation
>>
Get-ADUser : A parameter cannot be found that matches parameter name 'SearchRoo
t'.
At line:1 char:23
+ Get-ADUser -SearchRoot <<<<  "dc=ad,dc=local" `
    + CategoryInfo          : InvalidArgument: (:) [Get-ADUser], ParameterBind
   ingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.ActiveDirectory
   .Management.Commands.GetADUser

PS C:\Users\WhiteT>       Export-Csv C:\myscripts\ADusers.csv -NoTypeInformation


cmdlet Export-Csv at command pipeline position 1
Supply values for the following parameters:
InputObject: admin
Export-Csv : Could not find a part of the path 'C:\myscripts\ADusers.csv'.
At line:1 char:17
+       Export-Csv <<<<  C:\myscripts\ADusers.csv -NoTypeInformation
    + CategoryInfo          : OpenError: (:) [Export-Csv], DirectoryNotFoundEx
   ception
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.Ex
   portCsvCommand

PS C:\Users\WhiteT>
0
 
LVL 5

Accepted Solution

by:
coraxal earned 500 total points
Comment Utility
Sorry about that...I don't use the ActiveDirectory module too often. Anyway, the missing part was " -Filter * ". Here's the revised script (I tested):
Get-ADUser -Filter * -Properties whenCreated -SearchBase "DC=mydomain,DC=com" | 
        Select-Object SamAccountName,whenCreated |             
        Export-Csv "C:\myscripts\ADusers.csv" -NoTypeInformation

Open in new window


Also, not sure how you're running this script, but I'd suggest saving it (.ps1) and then run it from a shell window instead of copying and pasting the script directly into the shell.
0
 

Author Closing Comment

by:Twhite0909
Comment Utility
PERFECT!!  That worked beautifully Thank you SO much!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Experts-Exchange users below are the steps you can follow to upgrade your Lync server to latest CU's or cumulative updates. Note: Perform it during non-production hours.   Step 1: Backup your lync and SQL server database. Follow below article: h…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now