Newbie export data question

I am in the beginning phase of learning how to PowerShell. I am running this script.

Get-ADUser -Filter {(Enabled -eq $False)}
“Export-CSV C:\Temp\Disabledusers.CSV”

When I am running this script I am getting several extra pieces of data, I was wondering how to filter out specific parts of data so I don’t export what I don’t want. I will include all the data fields in a list below.

Distinguished Name, Enabled, Given Name, Name, ObjectClass, Object GUID, SamAccountName, SID, Surname, UserPrincipal Name.

When you post code, sample data, console output or error messages please format it as code using the preformatted text button ( </> ). Simply place your cursor on an empty line, click the button and paste your code.

Thanks in advance

How to format code in PowerShell.org <---- Click :point_up_2:t4: :wink:

And please always post the complete code you used in the way you used it.

To filter the output to some specific properties of your choice you use

So your snippet could look like this:

Get-ADUser -Filter 'Enabled -eq $False' -Properties DisplayName | 
Select-Object -Property sAMAccountName, DisplayName, DistinguishedName, Enabled |
Export-CSV -Path 'C:\Temp\Disabledusers.CSV' -NoTypeInformation

To reduce the stress you put on your DC with this kind of query it’s recommended to use always a -SearchBase for your queries.