Solved

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

Posted on 2016-10-16
9
51 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
  • 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
 
LVL 82

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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 14

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 14

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 82

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 14

Expert Comment

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

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Resolve DNS query failed errors for Exchange
This article will help you understand what HashTables are and how to use them in PowerShell.
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now