Skip to content

Instantly share code, notes, and snippets.

@Qazeer
Created September 5, 2022 19:14
Show Gist options
  • Save Qazeer/b4f3ce84aab3457004c29e8c0afb85a0 to your computer and use it in GitHub Desktop.
Save Qazeer/b4f3ce84aab3457004c29e8c0afb85a0 to your computer and use it in GitHub Desktop.
Powershell cmdlet to enumerate the attributes in Active Directory property sets
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