Solved

Assistance creating a powershell script that will export two User object attributes to an CSV file for a certain OU in active directory.

Posted on 2016-11-10
2
38 Views
Last Modified: 2016-11-10
I recently needed to create 2 attributes for user objects in active directory. I would like to export the list of users within a certain organizational unit (OU) and the two attributes I created to an excel file or CSV, whatever powershell will support for exporting. Can anyone recommend a powershell script that I can work with to accomplish this task. Thank you for your time.
0
Comment
Question by:Domenic DiPasquale
2 Comments
 
LVL 84

Accepted Solution

by:
oBdA earned 500 total points
ID: 41881973
You'll obviously have to replace Attribute1, Attribute2, and the OU path:
Get-ADUser -SearchBase "OU=SomeDeeperOU,OU=SomeOU,DC=contoso,DC=com" -Property Attribute1, Attribute2 |
	Select-Object -Property SamAccountName, DistinguishedName, Attribute1, Attribute2 |
	Export-Csv -Path C:\Temp\AttributeExport.csv -NoTypeInformation

Open in new window

0
 

Author Closing Comment

by:Domenic DiPasquale
ID: 41882026
The example you provided worked perfectly. Thank you for your help!
0

Featured Post

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

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

Suggested Solutions

In this previous article (https://oddytee.wordpress.com/2016/05/05/provision-new-office-365-user-and-mailbox-from-exchange-hybrid-via-powershell/), we made basic license assignments to users in O365. When I say basic, the method is the simplest way …
This article will help you understand what HashTables are and how to use them in PowerShell.
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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