mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-31 04:37:57 +00:00
Added exclusions
This commit is contained in:
@@ -6,10 +6,12 @@
|
|||||||
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
||||||
[System.Collections.IDictionary] $ExtendedForestInformation,
|
[System.Collections.IDictionary] $ExtendedForestInformation,
|
||||||
|
|
||||||
[ValidateSet('OK', 'Unlink', 'Delete')][string[]] $Option
|
[ValidateSet('OK', 'Unlink', 'Delete')][string[]] $Option,
|
||||||
|
[alias('ExcludeOU', 'Exclusions')][string[]] $ExcludeOrganizationalUnit
|
||||||
)
|
)
|
||||||
$CachedOu = [ordered] @{}
|
$CachedOu = [ordered] @{}
|
||||||
$CachedGPO = [ordered] @{}
|
$CachedGPO = [ordered] @{}
|
||||||
|
|
||||||
$ForestInformation = Get-WinADForestDetails -Extended -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
$ForestInformation = Get-WinADForestDetails -Extended -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
||||||
$GroupPolicies = Get-GPOZaurrAD -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
$GroupPolicies = Get-GPOZaurrAD -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
||||||
foreach ($GPO in $GroupPolicies) {
|
foreach ($GPO in $GroupPolicies) {
|
||||||
@@ -96,7 +98,6 @@
|
|||||||
$Status = 'OK'
|
$Status = 'OK'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($Option) {
|
if ($Option) {
|
||||||
$Found = $false
|
$Found = $false
|
||||||
if ($Option -contains 'Ok' -and $Status -contains 'OK') {
|
if ($Option -contains 'Ok' -and $Status -contains 'OK') {
|
||||||
@@ -106,12 +107,28 @@
|
|||||||
} elseif ($Option -contains 'Delete' -and $Status -contains 'Delete OU') {
|
} elseif ($Option -contains 'Delete' -and $Status -contains 'Delete OU') {
|
||||||
$Found = $true
|
$Found = $true
|
||||||
}
|
}
|
||||||
|
if ($ExcludeOrganizationalUnit) {
|
||||||
|
foreach ($ExcludedOU in $ExcludeOrganizationalUnit) {
|
||||||
|
if ($OU -like $ExcludedOU) {
|
||||||
|
$Found = $false
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if (-not $Found) {
|
if (-not $Found) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if ($ExcludeOrganizationalUnit) {
|
||||||
|
foreach ($ExcludedOU in $ExcludeOrganizationalUnit) {
|
||||||
|
if ($OU -like $ExcludedOU) {
|
||||||
|
$Status = 'Excluded'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
[PSCustomObject] @{
|
[PSCustomObject] @{
|
||||||
Organizationalunit = $OU
|
Organizationalunit = $OU
|
||||||
Level = $CachedOu[$OU]['Level']
|
Level = $CachedOu[$OU]['Level']
|
||||||
|
|||||||
Reference in New Issue
Block a user