mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-08-27 18:57:04 +00:00
Update
This commit is contained in:
@@ -7,7 +7,8 @@ function Get-GPOPrivLink {
|
|||||||
[string] $Domain,
|
[string] $Domain,
|
||||||
[switch] $SkipDomainRoot,
|
[switch] $SkipDomainRoot,
|
||||||
[switch] $SkipDomainControllers,
|
[switch] $SkipDomainControllers,
|
||||||
[switch] $AsHashTable
|
[switch] $AsHashTable,
|
||||||
|
[switch] $SkipDuplicates
|
||||||
)
|
)
|
||||||
foreach ($Object in $ADObject) {
|
foreach ($Object in $ADObject) {
|
||||||
if ($SkipDomainRoot) {
|
if ($SkipDomainRoot) {
|
||||||
|
|||||||
@@ -7,7 +7,8 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
[validateset('All', 'Root', 'DomainControllers', 'Site', 'OrganizationalUnit')][string[]] $Linked,
|
[validateset('All', 'Root', 'DomainControllers', 'Site', 'OrganizationalUnit')][string[]] $Linked,
|
||||||
[string] $SearchBase,
|
[string] $SearchBase,
|
||||||
[Microsoft.ActiveDirectory.Management.ADSearchScope] $SearchScope,
|
[Microsoft.ActiveDirectory.Management.ADSearchScope] $SearchScope,
|
||||||
[string] $Filter
|
[string] $Filter,
|
||||||
|
[switch] $SkipDuplicates
|
||||||
)
|
)
|
||||||
if (-not $ADObject) {
|
if (-not $ADObject) {
|
||||||
if (-not $Filter) {
|
if (-not $Filter) {
|
||||||
@@ -33,7 +34,7 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
if ($Linked -contains 'Site' -or $Linked -contains 'All') {
|
if ($Linked -contains 'Site' -or $Linked -contains 'All') {
|
||||||
Write-Verbose "Get-GPOZaurrLink - Getting GPO links for domain $Domain at SITE level"
|
Write-Verbose "Get-GPOZaurrLink - Getting GPO links for domain $Domain at SITE level"
|
||||||
@@ -47,7 +48,7 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($Linked -contains 'DomainControllers' -or $Linked -contains 'All') {
|
if ($Linked -contains 'DomainControllers' -or $Linked -contains 'All') {
|
||||||
@@ -60,7 +61,7 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
if ($Linked -contains 'OrganizationalUnit' -or $Linked -contains 'All') {
|
if ($Linked -contains 'OrganizationalUnit' -or $Linked -contains 'All') {
|
||||||
Write-Verbose "Get-GPOZaurrLink - Getting GPO links for domain $Domain at OU level"
|
Write-Verbose "Get-GPOZaurrLink - Getting GPO links for domain $Domain at OU level"
|
||||||
@@ -72,7 +73,7 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -SkipDomainRoot -SkipDomainControllers -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -SkipDomainRoot -SkipDomainControllers -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elseif ($Filter) {
|
} elseif ($Filter) {
|
||||||
@@ -102,10 +103,10 @@ function Get-GPOZaurrLinkLoop {
|
|||||||
} catch {
|
} catch {
|
||||||
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
Write-Warning "Get-GPOZaurrLink - Get-ADObject error $($_.Exception.Message)"
|
||||||
}
|
}
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObjectGPO -Domain $Domain -ForestInformation $ForestInformation -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObject -Domain '' -ForestInformation $ForestInformation -AsHashTable:$AsHashTable
|
Get-GPOPrivLink -CacheReturnedGPOs $CacheReturnedGPOs -ADObject $ADObject -Domain '' -ForestInformation $ForestInformation -AsHashTable:$AsHashTable -SkipDuplicates:$SkipDuplicates
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+41
-11
@@ -74,14 +74,14 @@
|
|||||||
$getGPOLoopSplat = @{
|
$getGPOLoopSplat = @{
|
||||||
Linked = $Linked
|
Linked = $Linked
|
||||||
ForestInformation = $ForestInformation
|
ForestInformation = $ForestInformation
|
||||||
CacheReturnedGPOs = $CacheReturnedGPOs
|
|
||||||
SearchScope = $SearchScope
|
SearchScope = $SearchScope
|
||||||
SearchBase = $SearchBase
|
SearchBase = $SearchBase
|
||||||
ADObject = $ADObject
|
ADObject = $ADObject
|
||||||
Filter = $Filter
|
Filter = $Filter
|
||||||
|
SkipDuplicates = $SkipDuplicates
|
||||||
}
|
}
|
||||||
Remove-EmptyValue -Hashtable $getGPOLoopSplat -Recursive
|
Remove-EmptyValue -Hashtable $getGPOLoopSplat -Recursive
|
||||||
|
$getGPOLoopSplat['CacheReturnedGPOs'] = $CacheReturnedGPOs
|
||||||
if ($AsHashTable -or $Summary) {
|
if ($AsHashTable -or $Summary) {
|
||||||
$HashTable = [ordered] @{}
|
$HashTable = [ordered] @{}
|
||||||
$SummaryHashtable = [ordered] @{}
|
$SummaryHashtable = [ordered] @{}
|
||||||
@@ -96,21 +96,51 @@
|
|||||||
foreach ($Key in $HashTable.Keys) {
|
foreach ($Key in $HashTable.Keys) {
|
||||||
[Array] $Link = $HashTable[$Key]
|
[Array] $Link = $HashTable[$Key]
|
||||||
$EnabledLinks = $Link.Enabled.Where( { $_ -eq $true }, 'split')
|
$EnabledLinks = $Link.Enabled.Where( { $_ -eq $true }, 'split')
|
||||||
|
|
||||||
|
$LinkedRoot = $false
|
||||||
|
$LinkedRootPlaces = [System.Collections.Generic.List[string]]::new()
|
||||||
|
$LinkedSite = $false
|
||||||
|
$LinkedSitePlaces = [System.Collections.Generic.List[string]]::new()
|
||||||
|
$LinkedOU = $false
|
||||||
|
$LinkedCrossDomain = $false
|
||||||
|
$LinkedCrossDomainPlaces = [System.Collections.Generic.List[string]]::new()
|
||||||
|
foreach ($InternalLink in $Link) {
|
||||||
|
if ($InternalLink.ObjectClass -eq 'domainDNS') {
|
||||||
|
$LinkedRoot = $true
|
||||||
|
$LinkedRootPlaces.Add($InternalLink.DistinguishedName)
|
||||||
|
} elseif ($InternalLink.ObjectClass -eq 'site') {
|
||||||
|
$LinkedSite = $true
|
||||||
|
$LinkedSitePlaces.Add($InternalLink.DistinguishedName)
|
||||||
|
} else {
|
||||||
|
$LinkedOU = $true
|
||||||
|
}
|
||||||
|
if ($InternalLink.DistinguishedName -notlike "*$($InternalLink.GPODomainDistinguishedName)*") {
|
||||||
|
$LinkedCrossDomain = $true
|
||||||
|
$LinkedCrossDomainPlaces.Add($InternalLink.DistinguishedName)
|
||||||
|
}
|
||||||
|
}
|
||||||
if ($EnabledLinks[0].Count -gt 0) {
|
if ($EnabledLinks[0].Count -gt 0) {
|
||||||
$IsLinked = $true
|
$IsLinked = $true
|
||||||
} else {
|
} else {
|
||||||
$IsLinked = $false
|
$IsLinked = $false
|
||||||
}
|
}
|
||||||
$SummaryLink = [PSCustomObject] @{
|
$SummaryLink = [PSCustomObject] @{
|
||||||
DisplayName = $Link[0].DisplayName
|
DisplayName = $Link[0].DisplayName
|
||||||
DomainName = $Link[0].DomainName
|
DomainName = $Link[0].DomainName
|
||||||
GUID = $Link[0].GUID
|
GUID = $Link[0].GUID
|
||||||
Linked = $IsLinked
|
Linked = $IsLinked
|
||||||
LinksCount = $Link.Count
|
LinksCount = $Link.Count
|
||||||
LinksEnabledCount = $EnabledLinks[0].Count
|
LinksEnabledCount = $EnabledLinks[0].Count
|
||||||
LinksDisabledCount = $EnabledLinks[1].Count
|
LinksDisabledCount = $EnabledLinks[1].Count
|
||||||
Links = $Link.DistinguishedName
|
LinkedCrossDomain = $LinkedCrossDomain
|
||||||
LinksObjects = $Link
|
LinkedRoot = $LinkedRoot
|
||||||
|
LinkedSite = $LinkedSite
|
||||||
|
LinkedOU = $LinkedOU
|
||||||
|
LinkedSitePlaces = $LinkedSitePlaces
|
||||||
|
LinkedRootPlaces = $LinkedRootPlaces
|
||||||
|
LinkedCrossDomainPlaces = $LinkedCrossDomainPlaces
|
||||||
|
Links = $Link.DistinguishedName
|
||||||
|
LinksObjects = $Link
|
||||||
}
|
}
|
||||||
$SummaryHashtable[$Key] = $SummaryLink
|
$SummaryHashtable[$Key] = $SummaryLink
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user