mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-09-03 22:25:22 +00:00
Update to Remove-PrivPermission
This commit is contained in:
@@ -2,6 +2,10 @@
|
|||||||
[cmdletBinding()]
|
[cmdletBinding()]
|
||||||
param(
|
param(
|
||||||
[Microsoft.GroupPolicy.Gpo] $GPO,
|
[Microsoft.GroupPolicy.Gpo] $GPO,
|
||||||
|
|
||||||
|
[string[]] $Principal,
|
||||||
|
[validateset('DistinguishedName', 'Name', 'Sid')][string] $PrincipalType = 'Sid',
|
||||||
|
|
||||||
[switch] $SkipWellKnown,
|
[switch] $SkipWellKnown,
|
||||||
[switch] $SkipAdministrative,
|
[switch] $SkipAdministrative,
|
||||||
[switch] $IncludeOwner,
|
[switch] $IncludeOwner,
|
||||||
@@ -9,7 +13,7 @@
|
|||||||
[Microsoft.GroupPolicy.GPPermissionType[]] $ExcludePermissionType,
|
[Microsoft.GroupPolicy.GPPermissionType[]] $ExcludePermissionType,
|
||||||
[switch] $IncludeGPOObject,
|
[switch] $IncludeGPOObject,
|
||||||
[System.Collections.IDictionary] $ADAdministrativeGroups,
|
[System.Collections.IDictionary] $ADAdministrativeGroups,
|
||||||
[validateSet('Unknown', 'NotWellKnown', 'NotWellKnownAdministrative', 'NotAdministrative', 'Administrative', 'All')][string[]] $Type,
|
[validateSet('Unknown', 'NotWellKnown', 'NotWellKnownAdministrative', 'NotAdministrative', 'Administrative', 'All', 'Default')][string[]] $Type,
|
||||||
[System.Collections.IDictionary] $Accounts
|
[System.Collections.IDictionary] $Accounts
|
||||||
)
|
)
|
||||||
Begin {
|
Begin {
|
||||||
@@ -58,6 +62,22 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($Principal) {
|
||||||
|
if ($PrincipalType -eq 'Sid') {
|
||||||
|
if ($Principal -notcontains $GPOPermission.Trustee.Sid.Value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} elseif ($PrincipalType -eq 'DistinguishedName') {
|
||||||
|
if ($Principal -notcontains $GPOPermission.Trustee.DSPath) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} elseif ($PrincipalType -eq 'Name') {
|
||||||
|
$UserMerge = -join ($GPOPermission.Trustee.Domain, '\', $GPOPermission.Trustee.Name)
|
||||||
|
if ($Principal -notcontains $UserMerge -and $Principal -notcontains $GPOPermission.Trustee.Name) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
$ReturnObject = [ordered] @{
|
$ReturnObject = [ordered] @{
|
||||||
DisplayName = $GPO.DisplayName # : ALL | Enable RDP
|
DisplayName = $GPO.DisplayName # : ALL | Enable RDP
|
||||||
GUID = $GPO.ID
|
GUID = $GPO.ID
|
||||||
@@ -105,7 +125,7 @@
|
|||||||
if ($IncludeGPOObject) {
|
if ($IncludeGPOObject) {
|
||||||
$ReturnObject['GPOObject'] = $GPO
|
$ReturnObject['GPOObject'] = $GPO
|
||||||
$ReturnObject['GPOSecurity'] = $SecurityRights
|
$ReturnObject['GPOSecurity'] = $SecurityRights
|
||||||
$ReturnObject['GPOSecurityPermissionIndex'] = $GPOPermission
|
$ReturnObject['GPOSecurityPermissionItem'] = $GPOPermission
|
||||||
}
|
}
|
||||||
[PSCustomObject] $ReturnObject
|
[PSCustomObject] $ReturnObject
|
||||||
}
|
}
|
||||||
@@ -175,7 +195,7 @@
|
|||||||
if ($IncludeGPOObject) {
|
if ($IncludeGPOObject) {
|
||||||
$ReturnObject['GPOObject'] = $GPO
|
$ReturnObject['GPOObject'] = $GPO
|
||||||
$ReturnObject['GPOSecurity'] = $SecurityRights
|
$ReturnObject['GPOSecurity'] = $SecurityRights
|
||||||
$ReturnObject['GPOSecurityPermissionIndex'] = $null
|
$ReturnObject['GPOSecurityPermissionItem'] = $null
|
||||||
}
|
}
|
||||||
[PSCustomObject] $ReturnObject
|
[PSCustomObject] $ReturnObject
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user