mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-08 09:53:13 +00:00
39 lines
1.6 KiB
PowerShell
39 lines
1.6 KiB
PowerShell
function Get-GPOPrivLink {
|
|
[cmdletBinding()]
|
|
param(
|
|
[parameter(ParameterSetName = 'ADObject', ValueFromPipeline, ValueFromPipelineByPropertyName, Mandatory)][Microsoft.ActiveDirectory.Management.ADObject[]] $ADObject,
|
|
[System.Collections.IDictionary] $CacheReturnedGPOs,
|
|
[System.Collections.IDictionary] $ForestInformation,
|
|
[string] $Domain,
|
|
[switch] $SkipDomainRoot,
|
|
[switch] $SkipDomainControllers,
|
|
[switch] $AsHashTable,
|
|
[switch] $SkipDuplicates
|
|
)
|
|
foreach ($Object in $ADObject) {
|
|
if ($SkipDomainRoot) {
|
|
if ($Object.DistinguishedName -eq $ForestInformation['DomainsExtended'][$Domain]['DistinguishedName']) {
|
|
# other skips Domain Root
|
|
continue
|
|
}
|
|
}
|
|
if ($SkipDomainControllers) {
|
|
if ($Object.DistinguishedName -eq $ForestInformation['DomainsExtended'][$Domain]['DomainControllersContainer']) {
|
|
# other skips Domain Controllers
|
|
continue
|
|
}
|
|
}
|
|
$OutputGPOs = Get-PrivGPOZaurrLink -Object $Object -Limited:$Limited.IsPresent -GPOCache $GPOCache
|
|
foreach ($OutputGPO in $OutputGPOs) {
|
|
if (-not $SkipDuplicates) {
|
|
$OutputGPO
|
|
} else {
|
|
$UniqueGuid = -join ($OutputGPO.DomainName, $OutputGPO.Guid)
|
|
if (-not $CacheReturnedGPOs[$UniqueGuid]) {
|
|
$CacheReturnedGPOs[$UniqueGuid] = $OutputGPO
|
|
$OutputGPO
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |