Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 119
  • Last Modified:

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

How to export first name, last name and creation date on 2008 active directory
0
Victor_Torres
Asked:
Victor_Torres
  • 3
  • 2
  • 2
  • +2
1 Solution
 
Victor_TorresAuthor Commented:
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
 
Nandu 45Commented:
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
 
Niten KumarPrincipal Systems AdministratorCommented:
import-module activedirectory

Get-ADUser -Filter * -Properties * | select givenName,surName,createtimestamp | Export-Csv C:\YourFolder\Report.csv
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
oBdACommented:
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
 
Todd NelsonSystems EngineerCommented:
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
 
Victor_TorresAuthor Commented:
Is it possible to query the user's date created on Active Directory on the management console?
0
 
Todd NelsonSystems EngineerCommented:
Are you asking about Server Manager or Active Directory Users and Computers?

Not that I am aware of from either.
1
 
oBdACommented:
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
 
Todd NelsonSystems EngineerCommented:
Of course, but not without going into each individual account.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

  • 3
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now