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
Solved

Create AD Query for User name and User Creation Date

Posted on 2013-01-21
8
601 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
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 

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

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

Suggested Solutions

Title # Comments Views Activity
SCOM Reporting 2 49
Exchange 2010 DAG backup 11 121
VAMT connectivity issues 1 552
scom operations console 2 58
Introduction: Sometimes when I receive a call from my users to solve their problems it is very difficult for me to found their computer IP address. Even finding their computer Host to provide remote support can be a problem.  So I resorted to Goo…
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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

809 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