mirror of
https://github.com/EvotecIT/GPOZaurr.git
synced 2026-09-04 14:45:23 +00:00
Small improvement to prevent detection of domain errors
This commit is contained in:
@@ -72,9 +72,13 @@
|
|||||||
# That's why we use $ForestInformation.Forest.Domains instead
|
# That's why we use $ForestInformation.Forest.Domains instead
|
||||||
foreach ($Domain in $ForestInformation.Forest.Domains) {
|
foreach ($Domain in $ForestInformation.Forest.Domains) {
|
||||||
Write-Verbose "Get-GPOZaurrLink - Building GPO cache for domain $Domain"
|
Write-Verbose "Get-GPOZaurrLink - Building GPO cache for domain $Domain"
|
||||||
$QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0]
|
if ($ForestInformation['QueryServers'][$Domain]) {
|
||||||
Get-GPO -All -DomainName $Domain -Server $QueryServer | ForEach-Object {
|
$QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0]
|
||||||
$GPOCache["$Domain$($_.ID.Guid)"] = $_
|
Get-GPO -All -DomainName $Domain -Server $QueryServer | ForEach-Object {
|
||||||
|
$GPOCache["$Domain$($_.ID.Guid)"] = $_
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Write-Warning -Message "Get-GPOZaurrLink - Couldn't get query server for $Domain. Skipped."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,23 @@
|
|||||||
function Get-GPOZaurrUpdates {
|
function Get-GPOZaurrUpdates {
|
||||||
[cmdletBinding()]
|
[cmdletBinding(DefaultParameterSetName = 'DateRange')]
|
||||||
param(
|
param(
|
||||||
|
[parameter(ParameterSetName = 'Dates')]
|
||||||
|
[parameter(ParameterSetName = 'DateRange')]
|
||||||
[alias('ForestName')][string] $Forest,
|
[alias('ForestName')][string] $Forest,
|
||||||
|
[parameter(ParameterSetName = 'Dates')]
|
||||||
|
[parameter(ParameterSetName = 'DateRange')]
|
||||||
[string[]] $ExcludeDomains,
|
[string[]] $ExcludeDomains,
|
||||||
|
[parameter(ParameterSetName = 'Dates')]
|
||||||
|
[parameter(ParameterSetName = 'DateRange')]
|
||||||
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
|
||||||
[DateTime] $DateFrom,
|
[parameter(Mandatory, ParameterSetName = 'Dates')][DateTime] $DateFrom,
|
||||||
[DateTime] $DateTo,
|
[parameter(Mandatory, ParameterSetName = 'Dates')][DateTime] $DateTo,
|
||||||
[ValidateSet('PastHour', 'CurrentHour', 'PastDay', 'CurrentDay', 'PastMonth', 'CurrentMonth', 'PastQuarter', 'CurrentQuarter', 'Last14Days', 'Last7Days', 'Last3Days', 'Last1Days')][string] $DateRange,
|
[parameter(Mandatory, ParameterSetName = 'DateRange')][ValidateSet('PastHour', 'CurrentHour', 'PastDay', 'CurrentDay', 'PastMonth', 'CurrentMonth', 'PastQuarter', 'CurrentQuarter', 'Last14Days', 'Last7Days', 'Last3Days', 'Last1Days')][string] $DateRange,
|
||||||
[ValidateSet('WhenCreated', 'WhenChanged')][string] $DateProperty = 'WhenCreated',
|
[parameter(ParameterSetName = 'Dates')]
|
||||||
|
[parameter(ParameterSetName = 'DateRange')]
|
||||||
|
[ValidateSet('WhenCreated', 'WhenChanged')][string[]] $DateProperty = 'WhenCreated',
|
||||||
|
[parameter(ParameterSetName = 'Dates')]
|
||||||
|
[parameter(ParameterSetName = 'DateRange')]
|
||||||
[System.Collections.IDictionary] $ExtendedForestInformation
|
[System.Collections.IDictionary] $ExtendedForestInformation
|
||||||
)
|
)
|
||||||
$getGPOZaurrADSplat = @{
|
$getGPOZaurrADSplat = @{
|
||||||
@@ -23,7 +33,14 @@
|
|||||||
Remove-EmptyValue -Hashtable $getGPOZaurrADSplat
|
Remove-EmptyValue -Hashtable $getGPOZaurrADSplat
|
||||||
# lets get all the links including sites
|
# lets get all the links including sites
|
||||||
|
|
||||||
Write-Verbose -Message "Get-GPOZaurrUpdates - Get group policies for defined ranges"
|
if ($DateRange) {
|
||||||
|
Write-Verbose -Message "Get-GPOZaurrUpdates - Get group policies for defined range $DateRange"
|
||||||
|
} elseif ($DateFrom -and $DateTo) {
|
||||||
|
Write-Verbose -Message "Get-GPOZaurrUpdates - Get group policies for defined range $DateFrom to $DateTo"
|
||||||
|
} else {
|
||||||
|
Write-Warning -Message "Get-GPOZaurrUpdates - No range is selected. Try again."
|
||||||
|
return
|
||||||
|
}
|
||||||
$LinksSummaryCache = Get-GPOZaurrLink -AsHashTable -Summary -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
$LinksSummaryCache = Get-GPOZaurrLink -AsHashTable -Summary -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
|
||||||
|
|
||||||
$OUCache = [ordered] @{}
|
$OUCache = [ordered] @{}
|
||||||
@@ -34,7 +51,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$CurrentCount = 0
|
$CurrentCount = 0
|
||||||
Write-Verbose -Message "Get-GPOZaurrUpdates - Getting all GPOs for defined ranges"
|
Write-Verbose -Message "Get-GPOZaurrUpdates - Getting GPO information"
|
||||||
[Array] $GPOs = Get-GPOZaurrAD @getGPOZaurrADSplat
|
[Array] $GPOs = Get-GPOZaurrAD @getGPOZaurrADSplat
|
||||||
foreach ($GPO in $GPOs) {
|
foreach ($GPO in $GPOs) {
|
||||||
$CurrentCount++
|
$CurrentCount++
|
||||||
@@ -58,15 +75,27 @@
|
|||||||
ObjectsClasses = @()
|
ObjectsClasses = @()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if ($GPO.Owner) {
|
||||||
|
$Owner = Get-WinADObject -Identity $GPO.Owner -AddType
|
||||||
|
} else {
|
||||||
|
$Owner = [PSCustomObject] @{
|
||||||
|
Name = 'Unknown'
|
||||||
|
Type = 'Unknown'
|
||||||
|
ObjectClass = 'Unknown'
|
||||||
|
}
|
||||||
|
}
|
||||||
[PSCustomObject] @{
|
[PSCustomObject] @{
|
||||||
DisplayName = $GPO.DisplayName
|
DisplayName = $GPO.DisplayName
|
||||||
DomainName = $GPO.DomainName
|
DomainName = $GPO.DomainName
|
||||||
Owner = $GPO.Owner
|
Owner = $GPO.Owner
|
||||||
|
OwnerName = $Owner.Name
|
||||||
|
OwnerType = $Owner.Type
|
||||||
|
OwnerClass = $Owner.ObjectClass
|
||||||
LinksCount = if ($GPOLinkData) { $GPOLinkData.LinksCount } else { 0 }
|
LinksCount = if ($GPOLinkData) { $GPOLinkData.LinksCount } else { 0 }
|
||||||
LinksEnabledCount = if ($GPOLinkData) { $GPOLinkData.LinksEnabledCount } else { 0 }
|
LinksEnabledCount = if ($GPOLinkData) { $GPOLinkData.LinksEnabledCount } else { 0 }
|
||||||
AffectedCount = $OrganizationalUnitsObjects.ObjectsTotalCount
|
AffectedCount = $OrganizationalUnitsObjects.ObjectsTotalCount
|
||||||
BlockedInheritanceCount = $OrganizationalUnitsObjects.ObjectsBlockedInheritanceCount
|
BlockedInheritanceCount = $OrganizationalUnitsObjects.ObjectsBlockedInheritanceCount
|
||||||
AffectedClasses = $OrganizationalUnitsObjects.ObjectsClasses
|
AffectedClasses = $OrganizationalUnitsObjects.ObjectsClasses.GetEnumerator().Name
|
||||||
Created = $GPO.Created
|
Created = $GPO.Created
|
||||||
Changed = $GPO.Modified
|
Changed = $GPO.Modified
|
||||||
LinksEnabled = $LinksDN
|
LinksEnabled = $LinksDN
|
||||||
|
|||||||
Reference in New Issue
Block a user