diff --git a/Examples/Example-40-ShowGPO01.ps1 b/Examples/Example-40-ShowGPO01.ps1 index c2aa181..71de96f 100644 --- a/Examples/Example-40-ShowGPO01.ps1 +++ b/Examples/Example-40-ShowGPO01.ps1 @@ -1,3 +1,7 @@ Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force -Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Type GPOPassword \ No newline at end of file +$Output = Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Type GPOPassword -PassThru +$Output + +Write-Color -Text 'Output of nested report' -Color DarkYellow -LinesBefore 1 -LinesAfter 1 +$Output.GPOPassword \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrAnalysis.ps1 b/Private/Invoke.GPOZaurrAnalysis.ps1 index 9a12b78..acc9701 100644 --- a/Private/Invoke.GPOZaurrAnalysis.ps1 +++ b/Private/Invoke.GPOZaurrAnalysis.ps1 @@ -21,5 +21,13 @@ New-HTMLTable -DataTable $Script:Reporting['GPOAnalysis']['Data'][$Key] -Filtering -Title $Key } } + if ($Script:Reporting['GPOAnalysis']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOAnalysis']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrBlockedInheritance.ps1 b/Private/Invoke.GPOZaurrBlockedInheritance.ps1 index 320d31e..b4bf832 100644 --- a/Private/Invoke.GPOZaurrBlockedInheritance.ps1 +++ b/Private/Invoke.GPOZaurrBlockedInheritance.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPOBlockedInheritance']['Data'] -Filtering + if ($Script:Reporting['GPOBlockedInheritance']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOBlockedInheritance']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrConsistency.ps1 b/Private/Invoke.GPOZaurrConsistency.ps1 index 0a0699b..e4d1e99 100644 --- a/Private/Invoke.GPOZaurrConsistency.ps1 +++ b/Private/Invoke.GPOZaurrConsistency.ps1 @@ -91,6 +91,15 @@ New-HTMLTableCondition -Name 'ACLConsistentInside' -Value 'Not available' -BackgroundColor Crimson -ComparisonType string } -PagingOptions 10, 20, 30, 40, 50 } + New-HTMLTable -DataTable $Script:Reporting['GPODuplicates']['Data'] -Filtering + if ($Script:Reporting['GPOConsistency']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOConsistency']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } New-HTMLSection -Name 'Steps to fix - Permissions Consistency' { New-HTMLContainer { New-HTMLSpanStyle -FontSize 10pt { diff --git a/Private/Invoke.GPOZaurrDuplicate.ps1 b/Private/Invoke.GPOZaurrDuplicate.ps1 index ba67b3e..3c786d3 100644 --- a/Private/Invoke.GPOZaurrDuplicate.ps1 +++ b/Private/Invoke.GPOZaurrDuplicate.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPODuplicates']['Data'] -Filtering + if ($Script:Reporting['GPODuplicates']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPODuplicates']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrFiles.ps1 b/Private/Invoke.GPOZaurrFiles.ps1 index 060a7ac..a82843c 100644 --- a/Private/Invoke.GPOZaurrFiles.ps1 +++ b/Private/Invoke.GPOZaurrFiles.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPOFiles']['Data'] -Filtering + if ($Script:Reporting['GPOFiles']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOFiles']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrList.ps1 b/Private/Invoke.GPOZaurrList.ps1 index 892ab4b..9aefe37 100644 --- a/Private/Invoke.GPOZaurrList.ps1 +++ b/Private/Invoke.GPOZaurrList.ps1 @@ -130,6 +130,14 @@ New-HTMLTableCondition -Name 'Linked' -Value $false -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string } -PagingOptions 10, 20, 30, 40, 50 } + if ($Script:Reporting['GPOList']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOList']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } New-HTMLSection -Name 'Steps to fix - Empty & Unlinked Group Policies' { New-HTMLContainer { New-HTMLSpanStyle -FontSize 10pt { diff --git a/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 b/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 index ef6118f..2e5fb7b 100644 --- a/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 +++ b/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 @@ -104,6 +104,14 @@ New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq } } + if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } New-HTMLSection -Name 'Steps to fix NetLogon Owners ' { New-HTMLContainer { New-HTMLSpanStyle -FontSize 10pt { diff --git a/Private/Invoke.GPOZaurrOrphans.ps1 b/Private/Invoke.GPOZaurrOrphans.ps1 index fd45439..d0701b7 100644 --- a/Private/Invoke.GPOZaurrOrphans.ps1 +++ b/Private/Invoke.GPOZaurrOrphans.ps1 @@ -96,6 +96,14 @@ New-HTMLTableCondition -Name 'Status' -Value "Permissions issue" -BackgroundColor MediumVioletRed -ComparisonType string -Color White } -PagingOptions 10, 20, 30, 40, 50 } + if ($Script:Reporting['GPOOrphans']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOOrphans']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } New-HTMLSection -Name 'Steps to fix - Not available on SYSVOL / Active Directory' { New-HTMLContainer { New-HTMLSpanStyle -FontSize 10pt { diff --git a/Private/Invoke.GPOZaurrOwners.ps1 b/Private/Invoke.GPOZaurrOwners.ps1 index f66b557..85a2564 100644 --- a/Private/Invoke.GPOZaurrOwners.ps1 +++ b/Private/Invoke.GPOZaurrOwners.ps1 @@ -104,6 +104,14 @@ New-HTMLTableCondition -Name 'IsOwnerAdministrative' -Value $false -BackgroundColor Salmon -ComparisonType string -Row } -PagingOptions 10, 20, 30, 40, 50 } + if ($Script:Reporting['GPOOwners']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOOwners']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } New-HTMLSection -Name 'Steps to fix Group Policy Owners' { New-HTMLContainer { New-HTMLSpanStyle -FontSize 10pt { diff --git a/Private/Invoke.GPOZaurrPassword.ps1 b/Private/Invoke.GPOZaurrPassword.ps1 index 4496058..3b882eb 100644 --- a/Private/Invoke.GPOZaurrPassword.ps1 +++ b/Private/Invoke.GPOZaurrPassword.ps1 @@ -17,5 +17,14 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPOPassword']['Data'] -Filtering + + if ($Script:Reporting['GPOPassword']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOPassword']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrPermissions.ps1 b/Private/Invoke.GPOZaurrPermissions.ps1 index 9135666..f98adb3 100644 --- a/Private/Invoke.GPOZaurrPermissions.ps1 +++ b/Private/Invoke.GPOZaurrPermissions.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPOPermissions']['Data'] -Filtering + if ($Script:Reporting['GPOPermissions']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOPermissions']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrPermissionsRoot.ps1 b/Private/Invoke.GPOZaurrPermissionsRoot.ps1 index 5df1e9d..4e3fc0a 100644 --- a/Private/Invoke.GPOZaurrPermissionsRoot.ps1 +++ b/Private/Invoke.GPOZaurrPermissionsRoot.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['GPOPermissionsRoot']['Data'] -Filtering + if ($Script:Reporting['GPOPermissionsRoot']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['GPOPermissionsRoot']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 b/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 index 5d77e35..d8dbf70 100644 --- a/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 +++ b/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 @@ -17,5 +17,13 @@ } Solution = { New-HTMLTable -DataTable $Script:Reporting['SysVolLegacyFiles']['Data'] -Filtering + if ($Script:Reporting['SysVolLegacyFiles']['WarningsAndErrors']) { + New-HTMLSection -Name 'Warnings & Errors to Review' { + New-HTMLTable -DataTable $Script:Reporting['SysVolLegacyFiles']['WarningsAndErrors'] -Filtering { + New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row + New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row + } + } + } } } \ No newline at end of file diff --git a/Public/Invoke-GPOZaurr.ps1 b/Public/Invoke-GPOZaurr.ps1 index 5e6f318..6744419 100644 --- a/Public/Invoke-GPOZaurr.ps1 +++ b/Public/Invoke-GPOZaurr.ps1 @@ -13,6 +13,7 @@ $Script:Reporting['Version'] = Get-GitHubVersion -Cmdlet 'Invoke-GPOZaurr' -RepositoryOwner 'evotecit' -RepositoryName 'GPOZaurr' Write-Color '[i]', "[GPOZaurr] ", 'Version', ' [Informative] ', $Script:Reporting['Version'] -Color Yellow, DarkGray, Yellow, DarkGray, Magenta + # Verify requested types are supported $Supported = [System.Collections.Generic.List[string]]::new() [Array] $NotSupported = foreach ($T in $Type) { if ($T -notin $Script:GPOConfiguration.Keys ) { @@ -30,7 +31,7 @@ return } - # Lets disable all current ones + # Lets make sure we only enable those types which are requestd by user if ($Type) { foreach ($T in $Script:GPOConfiguration.Keys) { $Script:GPOConfiguration[$T].Enabled = $false @@ -41,23 +42,39 @@ } } + # Build data foreach ($T in $Script:GPOConfiguration.Keys) { if ($Script:GPOConfiguration[$T].Enabled -eq $true) { $Script:Reporting[$T] = [ordered] @{ - Name = $Script:GPOConfiguration[$T].Name - ActionRequired = $null - Data = $null - Errors = $null - Warnings = $null - Time = $null - Variables = Copy-Dictionary -Dictionary $Script:GPOConfiguration[$T]['Variables'] + Name = $Script:GPOConfiguration[$T].Name + ActionRequired = $null + Data = $null + WarningsAndErrors = $null + Time = $null + Variables = Copy-Dictionary -Dictionary $Script:GPOConfiguration[$T]['Variables'] } $TimeLogGPOList = Start-TimeLog Write-Color -Text '[i]', '[Start] ', $($Script:GPOConfiguration[$T]['Name']) -Color Yellow, DarkGray, Yellow $Script:Reporting[$T]['Data'] = Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Execute'] -WarningVariable CommandWarnings -ErrorVariable CommandErrors Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Processing'] - $Script:Reporting[$T]['Warnings'] = $CommandWarnings - $Script:Reporting[$T]['Errors'] = $CommandErrors + $Script:Reporting[$T]['WarningsAndErrors'] = @( + foreach ($War in $CommandWarnings) { + [PSCustomObject] @{ + Type = 'Warning' + Comment = $War + Reason = '' + TargetName = '' + } + } + foreach ($Err in $CommandErrors) { + [PSCustomObject] @{ + Type = 'Error' + Comment = $Err + Reason = $Err.CategoryInfo.Reason + TargetName = $Err.CategoryInfo.TargetName + } + } + ) $TimeEndGPOList = Stop-TimeLog -Time $TimeLogGPOList -Option OneLiner $Script:Reporting[$T]['Time'] = $TimeEndGPOList Write-Color -Text '[i]', '[End ] ', $($Script:GPOConfiguration[$T]['Name']), " [Time to execute: $TimeEndGPOList]" -Color Yellow, DarkGray, Yellow, DarkGray