Skip to content

Instantly share code, notes, and snippets.

@HarmJ0y
Created November 17, 2017 00:21
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HarmJ0y/12cceda8dfa08102ce53a6cde620da2f to your computer and use it in GitHub Desktop.
Save HarmJ0y/12cceda8dfa08102ce53a6cde620da2f to your computer and use it in GitHub Desktop.
Enumerate cross-trust DACL control relationships
$Domain = "dev.testlab.local"
$DomainSid = Get-DomainSid $Domain
Get-DomainObjectAcl -Domain $Domain -ResolveGUIDs -LDAPFilter '(|(objectclass=groupPolicyContainer)(objectclass=group)(objectclass=user)(objectclass=domain))' | ? {
($_.AceType -match 'AccessAllowed') -and `
($_.SecurityIdentifier -match '^S-1-5-.*-[1-9]\d{3,}$') -and `
($_.SecurityIdentifier -notmatch $DomainSid) -and `
($_.ActiveDirectoryRights -match 'WriteProperty|GenericAll|GenericWrite|WriteDacl|WriteOwner')
} | % {
$_ | Add-Member Noteproperty 'PrincipalDN' $(Convert-ADName $_.SecurityIdentifier -OutputType DN)
$_
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment