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?
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 .
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.
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.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With