?
Solved

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

Posted on 2016-10-16
9
Medium Priority
?
108 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
Is Your AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

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

Office 365 Training for IT Pros

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

Question has a verified solution.

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

Had a business requirement to store the mobile number in an environmental variable. This is just a quick article on how this was done.
There are times when we need to generate a report on the inbox rules, where users have set up forwarding externally in their mailbox. In this article, I will be sharing a script I wrote to generate the report in CSV format.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

719 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