@@ -7438,7 +7438,8 @@ function Get-DomainObjectAcl {
74387438<#
74397439.SYNOPSIS
74407440
7441- Returns the ACLs associated with a specific active directory object.
7441+ Returns the ACLs associated with a specific active directory object. By default
7442+ the DACL for the object(s) is returned, but the SACL can be returned with -Sacl.
74427443
74437444Author: Will Schroeder (@harmj0y)
74447445License: BSD 3-Clause
@@ -7450,6 +7451,10 @@ A SamAccountName (e.g. harmj0y), DistinguishedName (e.g. CN=harmj0y,CN=Users,DC=
74507451SID (e.g. S-1-5-21-890171859-3433809279-3366196753-1108), or GUID (e.g. 4c435dd7-dc58-4b14-9a5e-1fdb0e80d201).
74517452Wildcards accepted.
74527453
7454+ .PARAMETER Sacl
7455+
7456+ Switch. Return the SACL instead of the DACL for the object (default behavior).
7457+
74537458.PARAMETER ResolveGUIDs
74547459
74557460Switch. Resolve GUIDs to their display names.
@@ -7511,6 +7516,12 @@ Enumerate the ACL permissions for all OUs in the domain.
75117516
75127517.EXAMPLE
75137518
7519+ Get-DomainOU | Get-DomainObjectAcl -ResolveGUIDs -Sacl
7520+
7521+ Enumerate the SACLs for all OUs in the domain, resolving GUIDs.
7522+
7523+ .EXAMPLE
7524+
75147525$SecPassword = ConvertTo-SecureString 'Password123!' -AsPlainText -Force
75157526$Cred = New-Object System.Management.Automation.PSCredential('TESTLAB\dfm.a', $SecPassword)
75167527Get-DomainObjectAcl -Credential $Cred -ResolveGUIDs
@@ -7531,6 +7542,9 @@ Custom PSObject with ACL entries.
75317542 [String[]]
75327543 $Identity,
75337544
7545+ [Switch]
7546+ $Sacl,
7547+
75347548 [Switch]
75357549 $ResolveGUIDs,
75367550
@@ -7580,9 +7594,15 @@ Custom PSObject with ACL entries.
75807594
75817595 BEGIN {
75827596 $SearcherArguments = @{
7583- 'SecurityMasks' = 'Dacl'
75847597 'Properties' = 'samaccountname,ntsecuritydescriptor,distinguishedname,objectsid'
75857598 }
7599+
7600+ if ($PSBoundParameters['Sacl']) {
7601+ $SearcherArguments['SecurityMasks'] = 'Sacl'
7602+ }
7603+ else {
7604+ $SearcherArguments['SecurityMasks'] = 'Dacl'
7605+ }
75867606 if ($PSBoundParameters['Domain']) { $SearcherArguments['Domain'] = $Domain }
75877607 if ($PSBoundParameters['SearchBase']) { $SearcherArguments['SearchBase'] = $SearchBase }
75887608 if ($PSBoundParameters['Server']) { $SearcherArguments['Server'] = $Server }
@@ -7655,8 +7675,7 @@ Custom PSObject with ACL entries.
76557675 }
76567676
76577677 try {
7658- New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList $Object['ntsecuritydescriptor'][0], 0 | Select-Object -Expand DiscretionaryAcl | ForEach-Object {
7659-
7678+ New-Object Security.AccessControl.RawSecurityDescriptor -ArgumentList $Object['ntsecuritydescriptor'][0], 0 | ForEach-Object { if ($PSBoundParameters['Sacl']) {$_.SystemAcl} else {$_.DiscretionaryAcl} } | ForEach-Object {
76607679 if ($PSBoundParameters['RightsFilter']) {
76617680 $GuidFilter = Switch ($RightsFilter) {
76627681 'ResetPassword' { '00299570-246d-11d0-a768-00aa006e0529' }
@@ -7677,7 +7696,6 @@ Custom PSObject with ACL entries.
76777696
76787697 if ($Continue) {
76797698 $_ | Add-Member NoteProperty 'ActiveDirectoryRights' ([Enum]::ToObject([System.DirectoryServices.ActiveDirectoryRights], $_.AccessMask))
7680-
76817699 if ($GUIDs) {
76827700 # if we're resolving GUIDs, map them them to the resolved hash table
76837701 $AclProperties = @{}
0 commit comments