@@ -7679,22 +7679,29 @@ System.Security.AccessControl.AuthorizationRule
76797679 )
76807680
76817681 Begin {
7682- $PrincipalSearcherArguments = @{
7683- 'Identity' = $PrincipalIdentity
7684- 'Properties' = 'distinguishedname,objectsid'
7682+ if ($PrincipalIdentity -notmatch '^S-1-.*') {
7683+ $PrincipalSearcherArguments = @{
7684+ 'Identity' = $PrincipalIdentity
7685+ 'Properties' = 'distinguishedname,objectsid'
7686+ }
7687+ if ($PSBoundParameters['PrincipalDomain']) { $PrincipalSearcherArguments['Domain'] = $PrincipalDomain }
7688+ if ($PSBoundParameters['Server']) { $PrincipalSearcherArguments['Server'] = $Server }
7689+ if ($PSBoundParameters['SearchScope']) { $PrincipalSearcherArguments['SearchScope'] = $SearchScope }
7690+ if ($PSBoundParameters['ResultPageSize']) { $PrincipalSearcherArguments['ResultPageSize'] = $ResultPageSize }
7691+ if ($PSBoundParameters['ServerTimeLimit']) { $PrincipalSearcherArguments['ServerTimeLimit'] = $ServerTimeLimit }
7692+ if ($PSBoundParameters['Tombstone']) { $PrincipalSearcherArguments['Tombstone'] = $Tombstone }
7693+ if ($PSBoundParameters['Credential']) { $PrincipalSearcherArguments['Credential'] = $Credential }
7694+ $Principal = Get-DomainObject @PrincipalSearcherArguments
7695+ if (-not $Principal) {
7696+ throw "Unable to resolve principal: $PrincipalIdentity"
7697+ }
7698+ elseif($Principal.Count -gt 1) {
7699+ throw "PrincipalIdentity matches multiple AD objects, but only one is allowed"
7700+ }
7701+ $ObjectSid = $Principal.objectsid
76857702 }
7686- if ($PSBoundParameters['PrincipalDomain']) { $PrincipalSearcherArguments['Domain'] = $PrincipalDomain }
7687- if ($PSBoundParameters['Server']) { $PrincipalSearcherArguments['Server'] = $Server }
7688- if ($PSBoundParameters['SearchScope']) { $PrincipalSearcherArguments['SearchScope'] = $SearchScope }
7689- if ($PSBoundParameters['ResultPageSize']) { $PrincipalSearcherArguments['ResultPageSize'] = $ResultPageSize }
7690- if ($PSBoundParameters['ServerTimeLimit']) { $PrincipalSearcherArguments['ServerTimeLimit'] = $ServerTimeLimit }
7691- if ($PSBoundParameters['Tombstone']) { $PrincipalSearcherArguments['Tombstone'] = $Tombstone }
7692- if ($PSBoundParameters['Credential']) { $PrincipalSearcherArguments['Credential'] = $Credential }
7693- $Principal = Get-DomainObject @PrincipalSearcherArguments
7694- if (-not $Principal) {
7695- throw "Unable to resolve principal: $PrincipalIdentity"
7696- } elseif($Principal.Count -gt 1) {
7697- throw "PrincipalIdentity matches multiple AD objects, but only one is allowed"
7703+ else {
7704+ $ObjectSid = $PrincipalIdentity
76987705 }
76997706
77007707 $ADRight = 0
@@ -7703,7 +7710,7 @@ System.Security.AccessControl.AuthorizationRule
77037710 }
77047711 $ADRight = [System.DirectoryServices.ActiveDirectoryRights]$ADRight
77057712
7706- $Identity = [System.Security.Principal.IdentityReference] ([System.Security.Principal.SecurityIdentifier]$Principal.objectsid )
7713+ $Identity = [System.Security.Principal.IdentityReference] ([System.Security.Principal.SecurityIdentifier]$ObjectSid )
77077714 }
77087715
77097716 Process {
0 commit comments