Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get specific properties with Get-AdUser

I have the following PS script written:

Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | Export-CSV "ADUsers.csv"

From what I can tell it should be returning only DisplayName. It's returning everything though. Problem is that DistinguishedName is causing truncation problems later on in my process. How can I get the script to only return certain properties?

like image 728
kickinchicken Avatar asked May 14 '13 13:05

kickinchicken


People also ask

How do I get user properties in PowerShell?

To use PowerShell to get AD user attributes, use the Property parameter. This parameter accepts one or more comma-delimited attributes to show with the output. Below you'll see an example of using Get-AdUser to find all properties for all user accounts with a givenName of Adam .

What is ADUser return?

Returns one or more user objects. This cmdlet returns a default set of ADUser property values. To retrieve additional ADUser properties, use the Properties parameter.

How do you get a list of all users from a specific OU?

Simply open the “User Accounts” report, specify the path to the OU you're interested in and run the report. You'll get a list of the members of that OU with the following user account properties: name, logon name and status.


1 Answers

using select-object for example:

Get-ADUser -Filter * -SearchBase 'OU=Users & Computers, DC=aaaaaaa, DC=com' -Properties DisplayName | select -expand displayname | Export-CSV "ADUsers.csv" 
like image 119
CB. Avatar answered Sep 18 '22 16:09

CB.