How to get list of all attribute in AD

Richa Kumari 301 Reputation points
2024-04-19T11:35:32.11+00:00

Hello,

How To get list of all attribute in AD(default and custom attribute ) in csv file.

Thanks

Rich

Windows for business Windows Client for IT Pros Directory services Active Directory
Windows for business Windows Server User experience PowerShell
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Marcin Policht 49,640 Reputation points MVP Volunteer Moderator
    2024-04-19T12:38:26.8233333+00:00

    Use the following:

    # Import Active Directory module
    Import-Module ActiveDirectory
    # Retrieve schema information for all attributes
    $attributes = Get-ADObject -SearchBase (Get-ADRootDSE).schemaNamingContext -LDAPFilter "(objectClass=attributeSchema)" -Properties * | Select-Object Name, Description
    # Export the attributes to a CSV file
    $attributes | Export-Csv -Path "AD_Attributes.csv" -NoTypeInformation
    
    

    If the above response helps answer your question, remember to "Accept Answer" so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.

    hth

    Marcin

    1 person found this answer helpful.

  2. Neuvi Jiang 1,540 Reputation points Microsoft External Staff
    2024-05-03T07:00:58.5466667+00:00

    Hi Richa Kumari,

    Thank you for posting on the Q&A Forum.

    To retrieve a list of all properties from Active Directory (including default and custom properties) and save them to a CSV file, you can use the following PowerShell script:

    
    Import-Module ActiveDirectory
    
    
    $allProperties = Get-ADObject -Filter * -Properties * | Get-Member -MemberType Property | Select-Object -ExpandProperty Name
    
    
    $allProperties | Export-Csv -Path "AD_Properties_List.csv" -NoTypeInformation
    

    After running this script, it will retrieve all properties of all objects in Active Directory and save the list of these properties to a CSV file named "AD_Properties_List.csv".

    Please note that this script will return all properties of all objects, which may include a large number of properties. If you only want to retrieve properties for specific types of objects (such as users, computers, etc.), you can specify the appropriate filter criteria in the Filter parameter of the Get-ADObject cmdlet.

    All the best

    Neuvi Jiang


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.