Created
September 5, 2022 19:14
-
-
Save Qazeer/b4f3ce84aab3457004c29e8c0afb85a0 to your computer and use it in GitHub Desktop.
Powershell cmdlet to enumerate the attributes in Active Directory property sets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-ADPropertySetsAttributes { | |
Param( | |
[Parameter(Mandatory=$False)][String]$Server = $null, | |
[Parameter(Mandatory=$False)][System.Management.Automation.PSCredential]$Credential = $null | |
) | |
$PSDefaultParameterValues = @{} | |
If ($Server) { | |
$PSDefaultParameterValues.Add("*-AD*:Server", $Server) | |
} | |
If ($Credential) { | |
$PSDefaultParameterValues.Add("*-AD*:Credential", $Credential) | |
} | |
$ADRootDSE = Get-ADRootDSE | |
$PropertySetRights = Get-ADObject -SearchBase "CN=Extended-Rights,$($ADRootDSE.configurationNamingContext)" -Filter { rightsGuid -like "*" } -Properties rightsGuid | |
$PropertySetsOutput = New-Object System.Collections.ArrayList | |
Foreach ($PropertySetRight in $PropertySetRights) { | |
$CurrentRightsGuid = [GUID] $PropertySetRight.rightsGuid | |
$CurrentPropertySetAttributes = Get-ADObject -SearchBase $ADRootDSE.schemaNamingContext -Filter { attributeSecurityGUID -eq $CurrentRightsGuid } -Properties * | |
Foreach ($CurrentPropertySetAttribute in $CurrentPropertySetAttributes) { | |
$null = $PropertySetsOutput.Add([PSCustomObject]@{ | |
PropertySetName = $PropertySetRight.Name | |
PropertySetRightsGuid = $CurrentRightsGuid | |
AttributeName = $CurrentPropertySetAttribute.Name | |
AttributeGuid = $([GUID] $CurrentPropertySetAttribute.schemaIDGUID).ToString() | |
}) | |
} | |
} | |
return $PropertySetsOutput | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment