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