Solved

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

Posted on 2016-10-16
9
77 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 84

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 15

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 15

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 84

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 15

Expert Comment

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

Featured Post

Guide to Performance: Optimization & Monitoring

Nowadays, monitoring is a mixture of tools, systems, and codes—making it a very complex process. And with this complexity, comes variables for failure. Get DZone’s new Guide to Performance to learn how to proactively find these variables and solve them before a disruption occurs.

Question has a verified solution.

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

A project that enables an administrator to perform actions within a user session context not just at the time of login but any time later on day(s) or week(s) later.
A quick Powershell script I wrote to find old program installations and check versions of a specific file across the network.
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…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

733 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