Solved

Create AD Query for User name and User Creation Date

Posted on 2013-01-21
8
592 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
ID: 38802345
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
ID: 38802854
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
ID: 38802877
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
ID: 38803036
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
Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

 
LVL 5

Expert Comment

by:coraxal
ID: 38803355
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
ID: 38805448
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
ID: 38807798
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
ID: 38809847
PERFECT!!  That worked beautifully Thank you SO much!
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Microsoft has released remote PowerShell capabilities to all commercial Office 365 customers. So you can be controlled via PowerShell and not from the Office 365 admin center Download Windows PowerShell Module for Lync Online http://www.micros…
This is a fairly complicated script that will install the required prerequisites to install SCCM 2012 R2 on a server.  It was designed under the functional model in order to compartmentalize each step required, reducing the overall complexity.  The …
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

895 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

12 Experts available now in Live!

Get 1:1 Help Now