Solved

How to export first name, last name and creation date on 2008 active directory

Posted on 2016-10-16
9
96 Views
Last Modified: 2016-10-27
How to export first name, last name and creation date on 2008 active directory
0
Comment
Question by:Victor_Torres
[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
  • 3
  • 2
  • 2
  • +2
9 Comments
 

Author Comment

by:Victor_Torres
ID: 41846168
I was able to extract first name and last name by using these command

dsquery user -name * -limit 0 | dsget user -fn -ln >c:\users_list.txt

How do I extract the date created ?
0
 

Expert Comment

by:Nandu 45
ID: 41846216
ActiveDirectory module requires the 2008R2 AD Web Services. That is the reason the Quest AD modules are there - and they should be used, as they make life easier.
Get-QADUser | select FirstName, LastName, email | Export-Csv -NoType C:\temp\users.csv
0
 
LVL 6

Expert Comment

by:Niten Kumar
ID: 41846379
import-module activedirectory

Get-ADUser -Filter * -Properties * | select givenName,surName,createtimestamp | Export-Csv C:\YourFolder\Report.csv
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 85

Expert Comment

by:oBdA
ID: 41846413
Powershell without the need for AD Cmdlets:
Function Get-ADSIUser {
[CmdletBinding()]
Param(
	[string]$SamAccountName = '*',
	[string[]]$AttributeList = @()
)
	If ($AttributeList.Count -eq 0) {
		$AttributeList = @(
			'createTimeStamp'
			'displayName'
			'distinguishedName'
			'givenName'
			'name'
			'sAMAccountName'
			'sn'
			'userPrincipalName'
		)
	}
	Try {
		$RootDSE = [ADSI]'LDAP://RootDSE'
		$ADODBConnection = New-Object -ComObject 'ADODB.Connection'
		$ADODBConnection.Provider = 'ADsDSOObject'
		$ADODBConnection.Open('Active Directory Provider')
		$ADODBCommand = New-Object -ComObject 'ADODB.Command'
		$ADODBCommand.ActiveConnection = $ADODBConnection
		$BaseDN = "LDAP://$($RootDSE.defaultNamingContext)"
		$Filter = "(&(objectCategory=person)(objectClass=user)(samaccountname=$($SamAccountName)))"
		$ADODBCommand.CommandText = "<" + $BaseDN + ">;" + $Filter + ";" + ($AttributeList -Join ",") + ";subtree"
		$ADODBCommand.Properties.Item('Page Size').Value = 1000
		$ADODBCommand.Properties.Item('Size Limit').Value = 10000
		$ADODBCommand.Properties.Item('Timeout').Value = 60
		$ADODBCommand.Properties.Item('Cache Results').Value = $False
		$RecordSet = $ADODBCommand.Execute()
		If ($RecordSet.EOF) {
			"User '$($SamAccountName)' not found!" | Write-Warning
		} Else {
			Do {
				$ADUser = '' | Select-Object -Property $AttributeList
				ForEach ($Attribute In $AttributeList) {
					$ADUser.$Attribute = $RecordSet.Fields.Item($Attribute).Value
				}
				$ADUser
				$RecordSet.MoveNext()
			} Until ($RecordSet.EOF)
		}
	} Catch {
		Throw $_
	} Finally {
		If ($RecordSet) {$RecordSet.Close()}
		If ($ADODBCommand) {[Runtime.InteropServices.Marshal]::FinalReleaseComObject($ADODBCommand) | Out-Null}
		If ($ADODBConnection) {
			$ADODBConnection.Close()
			[Runtime.InteropServices.Marshal]::FinalReleaseComObject($ADODBConnection) | Out-Null
		}
	}
}

Get-ADSIUser | Select-Object samAccountName, givenName, sn, createTimeStamp | Export-Csv -NoTypeInformation -Path C:\users_list.csv

Open in new window

0
 
LVL 16

Accepted Solution

by:
Todd Nelson earned 500 total points
ID: 41847150
Run this command in an elevated command prompt from the domain controller to get an output of users and date created in a CSV file...

csvde.exe -f "C:\AD-Users.csv" -r objectClass=user -l DisplayName,objectClass,userPrincipalName,givenName,sn,whenCreated

Open in new window


Keep in mind that the date in the whenCreated column will be formatted like this ... YYYYMMDDHHMMSS.  Therefore, "20160101062541.0Z" means that the account was created on 1 Janurary 2016 at 06:25:41 local time.
0
 

Author Comment

by:Victor_Torres
ID: 41849305
Is it possible to query the user's date created on Active Directory on the management console?
0
 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41849332
Are you asking about Server Manager or Active Directory Users and Computers?

Not that I am aware of from either.
1
 
LVL 85

Expert Comment

by:oBdA
ID: 41849473
In ADUC, first go the "View" menu and enable "Advanced Features".
Then open the properties of the object, and you'll find a tab "Object" with the Created and Modified dates.
0
 
LVL 16

Expert Comment

by:Todd Nelson
ID: 41849474
Of course, but not without going into each individual account.
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

For anyone that has accidentally used newSID with Server 2008 R2 (like I did) and hasn't been able to get the server running again because you were unlucky (as I was) and had no backups - I was able to get things working by doing a Registry Hive rec…
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

635 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