Export Active Directory Users Attribute of all users in a specify location

Hello,

Anyone know a tools where I can set in a windows schedule  task that will export in a CSV the First name & Last Name & Email Address & Display name of all the user located in a specific OU.

I have a Domain Control running Windows Server 2008

thanks
youpaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike KlineCommented:
You can use powershell and get-aduser  also lookup adinfo (free gui tool)

Thanks

Miks
0
Life1430Commented:
change the names as per your naming convention and configure below command in scheduled task

dsquery user "OU,OUname,DC=domain,DC=local" -limit 0 | dsget user -display -email -pager>c:\Users.csv

Open in new window

0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
Command below will export all attributes for users:

Dsquery * -limit 0 -filter "&(objectClass=User)(objectCategory=Person)" -attr * >> output.txt
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

w_richardCommented:
For exporting this can be done manually...

This scripts is tested scripts...

Hope it helps you.

Import-Module ActiveDirectory

#Create a variable for the date stamp in the log file
$LogDate = get-date -f yyyyMMddhhmm
#Sets the OU to do the base search for all user accounts, change for your env.
$SearchBase = "OU=****,DC=****,DC=com"
#Create an empty array for the log file
$LogArray = @()

$Users = @(Import-Csv "e:\temp\Leavers.csv")
ForEach ($User In $Users)
{
$Filter = "(company=" + $User."Employee ID" + ")"
$Return = Get-ADUser -searchbase $SearchBase -LDAPFilter $Filter
#Create new object for logging
If ($Return){
#Amend the users description
set-aduser $Return -Description ("Identified Leaver - Disabled on "+(get-date).toshortdatestring())
#Disables user object.
Disable-ADAccount $Return
#Moves the account
Move-ADObject $Return -TargetPath "OU=Users,OU=****,OU=Inactifs,DC=****,DC=com"
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Name" -Value $Return.name
$obj | Add-Member -MemberType NoteProperty -Name "Account Name" -Value $Return.samaccountname
$obj | Add-Member -MemberType NoteProperty -Name "Employee ID" -Value $User."Employee ID"
$obj | Add-Member -MemberType NoteProperty -Name "DistinguishedName" -Value $Return.DistinguishedName
#Adds object to the log array
$LogArray += $obj
}
}

#Exports log array to HTML file in the temp directory with a date and time stamp in the file name.
$a = "<style>"
$a = $a + "BODY{background-color:#D0D0D0;}"
$a = $a + "TABLE{border-width: 2px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 2px;padding: 0px;border-style: solid;border-color: black;background-color:#CC0000}"
$a = $a + "TD{border-width: 2px;padding: 0px;border-style: solid;border-color: black;background-color:#D0D0D0}"
$a = $a + "</style>"
$logArray | ConvertTo-HTML -head $a -body "<H2>Leavers Report</H2>"| Out-File "\\*****\Reports\Users_Leaver_Report_$logDate.html " 


##Creates and sends completion email with information##
$emailFrom = "AD-Scripts@*****.com"
$emailTo = "****.Admins@***.com"
$subject = "AD Users Leaver Script Complete"
$smtpServer = "*****"
$body = "The monthly AD Leavers script has run.`r`n"+
"`r`n"+
"`r`n"+
"Report is located \\*****\Reports\User_Leavers_Report_$logDate.html"

Send-MailMessage -To $emailTo -From $emailFrom -Subject $subject -Body $body -SmtpServer $smtpServer

Thanks.
0
youpaAuthor Commented:
This command work fine , however it's only giving the display name, I would like also to have First Name and Lastname.

dsquery user "OU,OUname,DC=domain,DC=local" -limit 0 | dsget user -display -email -pager>c:\Users.csv


thanks
0
Mike KlineCommented:
Just add a few more attributes and you should be good to go

dsquery user "OU,OUname,DC=domain,DC=local" -limit 0 | dsget user -display -email     -fn -ln pager>c:\Users.csv

List of attributes can be found  http://technet.microsoft.com/en-us/library/cc732535.aspx

Thanks

Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mike KlineCommented:
Thanks a lot for the points and glad to help.   Just a heads up next time you can also split points for several helpful answers.

Thanks

Mike
0
youpaAuthor Commented:
Thanks all
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.