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?
This question is related to
powershell
active-directory
powershell-2.0
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"
This worked for me as well:
Get-ADUser -Filter * -SearchBase "ou=OU,dc=Domain,dc=com" -Properties Enabled, CanonicalName, Displayname, Givenname, Surname, EmployeeNumber, EmailAddress, Department, StreetAddress, Title | select Enabled, CanonicalName, Displayname, GivenName, Surname, EmployeeNumber, EmailAddress, Department, Title | Export-CSV "C:\output.csv"
Source: Stackoverflow.com