Solved

Create AD Query for User name and User Creation Date

Posted on 2013-01-21
8
623 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
[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
  • Learn & ask questions
  • 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
Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

 

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

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

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

I have put this article together as i needed to get all the information that might be available already into one general document that could be referenced once without searching the Internet for the different pieces. I have had a few issues where…
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…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 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