Get AD Attributes List of any AD Object using PowerShell

List Attributes of any Active Directory object

Most PowerShell scripts available in the internet can help administrators retrieve certain common attributes of an user, group, or a computer. Most scripts either document only specified attributes, or at best only the attributes that have been assigned values. However, if one had to document all the attributes assigned to a specific Active Directory object, the options are few.
 
The following PowerShell script will return all attributes of a specific object. Provide the object's DistinguisedName as a parameter and run the script to return all the attributes. 
Script

<#
.SYNOPSIS
This script can be used to list all attributes of any active directory object.
.DESCRIPTION
This script can be used to list all attributes of any active directory object.
.EXAMPLE
C:\PS> C:\Script\Attributes_of_an_object.ps1 “CN=Administrator,CN=Users,DC=xchange,DC=com”
Lists all attributes of user Administrator.
#>

param([String]$dname)
#Fetches the object for which attributes has to be listed.

$obj = [ADSI](“LDAP://” + “$dname”)
#Fetches a collection of all attributes of the object.

$colObjProps = $obj | get-member
#Lists the attributes one by one.

foreach ($prop in $colObjProps)
{
write-host $prop.Name -nonewline
write-host “: ” -nonewline
write-host $obj.($prop.Name)
}

 

Post navigation


    • Related Articles

    • Creating a custom object in Active Directory

      There may be instances where the objects available in an Active Directory (AD) schema do not suit your organization's requirements. In this case, you can create a custom AD object that suits your organization's needs. This task can be done easily ...
    • How to add/remove Active Directory users to Active Directory groups using PowerShell

      Active Directory is a powerful tool for managing users and groups in a Windows environment. One of the most often-repeated tasks for administrators is to add or remove users from Active Directory groups. In this article, we will explore how to ...
    • Add Attributes to Global Catalog Replication

      It is common for IT admins to notice that few AD attributes are not natively in the global catalog replication set. Adding these attributes to the Global Catalog replication set is necessary so that all the DC's in the network carry the updated ...
    • How to manage inactive Active Directory user accounts

      Over time, an organization's Active Directory (AD) network can start accumulating inactive user accounts. These accounts can be of employees who may have left the organization, temporary accounts, etc. The problem here is that these inactive AD ...
    • How to get memberships of the Active Directory user using PowerShell

      One of the essential parts of Active Directory administration is to manage user memberships in Active Directory. There may be times when the membership of a specific user need to be identified. In this article, we will explain how to use PowerShell ...