From b5e4fd07dc5b58c974f4d5ddb55be16bb1555743 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Thu, 5 Nov 2020 11:28:58 +0100 Subject: [PATCH] Update --- Private/Invoke.GPOZaurrAnalysis.ps1 | 22 ++ Private/Invoke.GPOZaurrFiles.ps1 | 18 + Private/Invoke.GPOZaurrList.ps1 | 183 ++++++++++ .../Invoke.GPOZaurrNetLogonPermissions.ps1 | 65 ++++ Private/Invoke.GPOZaurrOrphans.ps1 | 129 +++++++ Private/Invoke.GPOZaurrPermissions.ps1 | 18 + Private/Invoke.GPOZaurrPermissionsRoot.ps1 | 18 + Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 | 18 + Private/Script.GPOConfiguration.ps1 | 164 +-------- Public/Invoke-GPOZaurr.ps1 | 343 ------------------ 10 files changed, 482 insertions(+), 496 deletions(-) create mode 100644 Private/Invoke.GPOZaurrAnalysis.ps1 create mode 100644 Private/Invoke.GPOZaurrFiles.ps1 create mode 100644 Private/Invoke.GPOZaurrList.ps1 create mode 100644 Private/Invoke.GPOZaurrNetLogonPermissions.ps1 create mode 100644 Private/Invoke.GPOZaurrOrphans.ps1 create mode 100644 Private/Invoke.GPOZaurrPermissions.ps1 create mode 100644 Private/Invoke.GPOZaurrPermissionsRoot.ps1 create mode 100644 Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 diff --git a/Private/Invoke.GPOZaurrAnalysis.ps1 b/Private/Invoke.GPOZaurrAnalysis.ps1 new file mode 100644 index 0000000..355d42a --- /dev/null +++ b/Private/Invoke.GPOZaurrAnalysis.ps1 @@ -0,0 +1,22 @@ +$GPOZaurrAnalysis = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + + } + Solution = { + foreach ($Key in $GPOContent.Keys) { + New-HTMLTab -Name $Key { + New-HTMLTable -DataTable $GPOContent[$Key] -Filtering -Title $Key + } + } + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrFiles.ps1 b/Private/Invoke.GPOZaurrFiles.ps1 new file mode 100644 index 0000000..16c0ed5 --- /dev/null +++ b/Private/Invoke.GPOZaurrFiles.ps1 @@ -0,0 +1,18 @@ +$GPOZaurrFiles = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + + } + Solution = { + New-HTMLTable -DataTable $GPOFiles -Filtering + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrList.ps1 b/Private/Invoke.GPOZaurrList.ps1 new file mode 100644 index 0000000..ab26db5 --- /dev/null +++ b/Private/Invoke.GPOZaurrList.ps1 @@ -0,0 +1,183 @@ +$GPOZaurrList = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + $GPOSummary = Get-GPOZaurr + $GPONotLinked = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOLinked = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPONotEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOEmptyAndUnlinked = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOEmptyOrUnlinked = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOLinkedButEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOValid = [System.Collections.Generic.List[PSCustomObject]]::new() + $GPOLinkedButLinkDisabled = [System.Collections.Generic.List[PSCustomObject]]::new() + foreach ($GPO in $GPOSummary) { + if ($GPO.Linked -eq $false -and $GPO.Empty -eq $true) { + # Not linked, Empty + $GPOEmptyAndUnlinked.Add($GPO) + $GPOEmptyOrUnlinked.Add($GPO) + $GPONotLinked.Add($GPO) + $GPOEmpty.Add($GPO) + } elseif ($GPO.Linked -eq $true -and $GPO.Empty -eq $true) { + # Linked, But EMPTY + $GPOLinkedButEmpty.Add($GPO) + $GPOEmptyOrUnlinked.Add($GPO) + $GPOEmpty.Add($GPO) + $GPOLinked.Add($GPO) + } elseif ($GPO.Linked -eq $false) { + # Not linked, but not EMPTY + $GPONotLinked.Add($GPO) + $GPOEmptyOrUnlinked.Add($GPO) + $GPONotEmpty.Add($GPO) + } elseif ($GPO.Empty -eq $true) { + # Linked, But EMPTY + $GPOEmpty.Add($GPO) + $GPOEmptyOrUnlinked.Add($GPO) + $GPOLinked.Add($GPO) + } else { + # Linked, not EMPTY + $GPOValid.Add($GPO) + $GPOLinked.Add($GPO) + $GPONotEmpty.Add($GPO) + } + if ($GPO.LinksDisabledCount -eq $GPO.LinksCount -and $GPO.LinksCount -gt 0) { + $GPOLinkedButLinkDisabled.Add($GPO) + } + } + $GPOTotal = $GPOSummary.Count + } + Variables = @{ + + } + Overview = { + New-HTMLPanel { + New-HTMLText -Text 'Following chart presents ', 'Linked / Empty and Unlinked Group Policies' -FontSize 10pt -FontWeight normal, bold + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies total: ', $GPOTotal -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies valid: ", $GPOValid.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies to delete: ", $GPOEmptyOrUnlinked.Count -FontWeight normal, bold { + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPONotLinked.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOEmpty.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOLinkedButEmpty.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOLinkedButLinkDisabled.Count -FontWeight normal, bold + } + } + } -FontSize 10pt + New-HTMLText -FontSize 10pt -Text 'Usually empty or unlinked Group Policies are safe to delete.' + New-HTMLChart -Title 'Group Policies Summary' { + New-ChartBarOptions -Type barStacked + #New-ChartLegend -Names 'Unlinked', 'Linked', 'Empty', 'Total' -Color Salmon, PaleGreen, PaleVioletRed, PaleTurquoise + New-ChartLegend -Names 'Good', 'Bad' -Color PaleGreen, Salmon + #New-ChartBar -Name 'Group Policies' -Value $GPONotLinked.Count, $GPOLinked.Count, $GPOEmpty.Count, $GPOTotal + New-ChartBar -Name 'Linked' -Value $GPOLinked.Count, $GPONotLinked.Count + New-ChartBar -Name 'Empty' -Value $GPONotEmpty.Count, $GPOEmpty.Count + New-ChartBar -Name 'Valid' -Value $GPOValid.Count, $GPOEmptyOrUnlinked.Count + } -TitleAlignment center + } + } + Solution = { + New-HTMLPanel { + $newHTMLTextSplat = @{ + Text = @( + 'Following table shows a list of group policies.', + 'By using following table you can easily find which GPOs can be safely deleted because those are empty or unlinked or linked, but link disabled.' + ) + FontSize = '10pt' + FontWeight = 'normal', 'bold' + } + New-HTMLText @newHTMLTextSplat + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies total: ', $GPOTotal -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies valid: ", $GPOValid.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies to delete: ", $GPOEmptyOrUnlinked.Count -FontWeight normal, bold { + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPONotLinked.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOEmpty.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOLinkedButEmpty.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOLinkedButLinkDisabled.Count -FontWeight normal, bold + } + } + } -FontSize 10pt + New-HTMLText -Text 'All those mentioned Group Policies can be automatically deleted following the steps below the table.' -FontSize 10pt + } + New-HTMLSection -Name 'Group Policies List' { + New-HTMLTable -DataTable $GPOSummary -Filtering { + New-HTMLTableCondition -Name 'Empty' -Value $true -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string + New-HTMLTableCondition -Name 'Linked' -Value $false -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string + } -PagingOptions 10, 20, 30, 40, 50 + } + New-HTMLSection -Name 'Steps to fix - Empty & Unlinked Group Policies' { + New-HTMLContainer { + New-HTMLSpanStyle -FontSize 10pt { + New-HTMLText -Text 'Following steps will guide you how to remove empty or unlinked group policies' + New-HTMLWizard { + New-HTMLWizardStep -Name 'Prepare environment' { + New-HTMLText -Text "To be able to execute actions in automated way please install required modules. Those modules will be installed straight from Microsoft PowerShell Gallery." + New-HTMLCodeBlock -Code { + Install-Module GPOZaurr -Force + Import-Module GPOZaurr -Force + } -Style powershell + New-HTMLText -Text "Using force makes sure newest version is downloaded from PowerShellGallery regardless of what is currently installed. Once installed you're ready for next step." + } + New-HTMLWizardStep -Name 'Prepare report' { + New-HTMLText -Text "Depending when this report was run you may want to prepare new report before proceeding with removal. To generate new report please use:" + New-HTMLCodeBlock -Code { + Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrEmptyUnlinked.html -Verbose -Type GPOList + } + New-HTMLText -TextBlock { + "When executed it will take a while to generate all data and provide you with new report depending on size of environment." + "Once confirmed that data is still showing issues and requires fixing please proceed with next step." + } + New-HTMLText -Text "Alternatively if you prefer working with console you can run: " + New-HTMLCodeBlock -Code { + $GPOOutput = Get-GPOZaurr + $GPOOutput | Format-Table + } + New-HTMLText -Text "It provides same data as you see in table above just doesn't prettify it for you." + } + New-HTMLWizardStep -Name 'Remove GPOs that are EMPTY or UNLINKED' { + New-HTMLText -Text @( + "Following command when executed removes every ", + "EMPTY" + " or " + "NOT LINKED" + " Group Policy. Make sure when running it for the first time to run it with ", + "WhatIf", + " parameter as shown below to prevent accidental removal.", + "Make sure to use BackupPath which will make sure that for each GPO that is about to be deleted a backup is made to folder on a desktop." + ) -FontWeight normal, bold, normal, bold, normal, bold, normal, normal -Color Black, Red, Black, Red, Black + New-HTMLCodeBlock -Code { + Remove-GPOZaurr -Type Empty, Unlinked -BackupPath "$Env:UserProfile\Desktop\GPO" -Verbose -WhatIf + } + New-HTMLText -TextBlock { + "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " + } + New-HTMLCodeBlock -Code { + Remove-GPOZaurr -Type Empty, Unlinked -BackupPath "$Env:UserProfile\Desktop\GPO" -LimitProcessing 2 -Verbose + } + New-HTMLText -TextBlock { + "This command when executed deletes only first empty or unlinked GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." + "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." + "Please make sure to check if backup is made as well before going all in." + } + New-HTMLText -Text "If there's nothing else to be deleted on SYSVOL side, we can skip to next step step" + } + New-HTMLWizardStep -Name 'Verification report' { + New-HTMLText -TextBlock { + "Once cleanup task was executed properly, we need to verify that report now shows no problems." + } + New-HTMLCodeBlock -Code { + Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrEmptyUnlinkedAfter.html -Verbose -Type GPOList + } + New-HTMLText -Text "If there are no more empty or unlinked GPOs in the report you're done! Enjoy rest of the day!" -Color BlueDiamond + } + } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center + } + } + } + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 b/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 new file mode 100644 index 0000000..0f6a512 --- /dev/null +++ b/Private/Invoke.GPOZaurrNetLogonPermissions.ps1 @@ -0,0 +1,65 @@ +$GPOZaurrNetLogonPermissions = [ordered] @{ + Name = 'NetLogon Permissions' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + New-HTMLPanel { + New-HTMLText -Text 'Following chart presents ', 'NetLogon Summary' -FontSize 10pt -FontWeight normal, bold + New-HTMLList -Type Unordered { + & $Script:GPOConfiguration['NetLogon']['List'] + } -FontSize 10pt + #New-HTMLText -FontSize 10pt -Text 'Those problems must be resolved before doing other clenaup activities.' + New-HTMLChart { + New-ChartPie -Name 'Correct Owners' -Value $NetLogonOwnersAdministrators.Count -Color LightGreen + New-ChartPie -Name 'Incorrect Owners' -Value $NetLogonOwnersToFix.Count -Color Crimson + } -Title 'NetLogon Owners' -TitleAlignment center + } + New-HTMLPanel { + + } + } + Solution = { + New-HTMLTab -Name 'NetLogon Owners' { + New-HTMLPanel { + New-HTMLText -TextBlock { + "Following table shows NetLogon file owners. It's important that NetLogon file owners are set to BUILTIN\Administrators (SID: S-1-5-32-544). " + "Owners have full control over the file object. Current owner of the file may be an Administrator but it doesn't guarentee that he will be in the future. " + "That's why as a best-practice it's recommended to change any non-administrative owners to BUILTIN\Administrators, and even Administrative accounts should be replaced with it. " + } -FontSize 10pt + New-HTMLList -Type Unordered { + & $Script:GPOConfiguration['NetLogon']['List'] + } -FontSize 10pt + New-HTMLText -Text "Follow the steps below table to get NetLogon Owners into compliant state." -FontSize 10pt + } + New-HTMLSection -Name 'NetLogon Files List' { + New-HTMLTable -DataTable $NetLogonOwners -Filtering { + New-HTMLTableCondition -Name 'PrincipalSid' -Value "S-1-5-32-544" -BackgroundColor LightGreen -ComparisonType string + New-HTMLTableCondition -Name 'PrincipalSid' -Value "S-1-5-32-544" -BackgroundColor Salmon -ComparisonType string -Operator ne + New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq + } + } + New-HTMLSection -Name 'Steps to fix NetLogon Owners ' { + New-HTMLContainer { + New-HTMLSpanStyle -FontSize 10pt { + New-HTMLText -Text 'Following steps will guide you how to fix NetLogon Owners and make them compliant.' + New-HTMLWizard { + & $Script:GPOConfiguration['NetLogon']['Wizard'] + } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center + } + } + } + } + New-HTMLTab -Name 'NetLogon Permissions' { + New-HTMLSection -Name 'NetLogon Files List' { + New-HTMLTable -DataTable $Netlogon -Filtering + } + } + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrOrphans.ps1 b/Private/Invoke.GPOZaurrOrphans.ps1 new file mode 100644 index 0000000..2a31dfa --- /dev/null +++ b/Private/Invoke.GPOZaurrOrphans.ps1 @@ -0,0 +1,129 @@ +$GPOZaurrOrphans = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + New-HTMLPanel { + New-HTMLText -Text 'Following chart presents ', 'Broken / Orphaned Group Policies' -FontSize 10pt -FontWeight normal, bold + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies on SYSVOL, but no details in AD: ', $NotAvailableInAD.Count -FontWeight normal, bold + New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $NotAvailableOnSysvol.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $NotAvailablePermissionIssue.Count -FontWeight normal, bold + } -FontSize 10pt + New-HTMLText -FontSize 10pt -Text 'Those problems must be resolved before doing other clenaup activities.' + New-HTMLChart { + New-ChartBarOptions -Type barStacked + New-ChartLegend -Name 'Not in AD', 'Not on SYSVOL', 'Permissions Issue' -Color Crimson, LightCoral, IndianRed + New-ChartBar -Name 'Orphans' -Value $NotAvailableInAD.Count, $NotAvailableOnSysvol.Count, $NotAvailablePermissionIssue.Count + } -Title 'Broken / Orphaned Group Policies' -TitleAlignment center + } + } + Solution = { + New-HTMLPanel { + New-HTMLText -TextBlock { + "Following table shows list of all group policies and their status in AD and SYSVOL. Due to different reasons it's " + "possible that " + } -FontSize 10pt + New-HTMLList -Type Unordered { + New-HTMLListItem -Text 'Group Policies on SYSVOL, but no details in AD: ', $NotAvailableInAD.Count -FontWeight normal, bold + New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $NotAvailableOnSysvol.Count -FontWeight normal, bold + New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $NotAvailablePermissionIssue.Count -FontWeight normal, bold + } -FontSize 10pt + New-HTMLText -Text "Follow the steps below table to get Active Directory Group Policies in healthy state." -FontSize 10pt + } + New-HTMLSection -Name 'Health State of Group Policies' { + New-HTMLTable -DataTable $GPOOrphans -Filtering { + New-HTMLTableCondition -Name 'Status' -Value "Not available in AD" -BackgroundColor Salmon -ComparisonType string + New-HTMLTableCondition -Name 'Status' -Value "Not available on SYSVOL" -BackgroundColor LightCoral -ComparisonType string + New-HTMLTableCondition -Name 'Status' -Value "Permissions issue" -BackgroundColor MediumVioletRed -ComparisonType string -Color White + } -PagingOptions 10, 20, 30, 40, 50 + } + New-HTMLSection -Name 'Steps to fix - Not available on SYSVOL / Active Directory' { + New-HTMLContainer { + New-HTMLSpanStyle -FontSize 10pt { + New-HTMLText -Text 'Following steps will guide you how to fix GPOs which are not available on SYSVOL or AD.' + New-HTMLWizard { + New-HTMLWizardStep -Name 'Prepare environment' { + New-HTMLText -Text "To be able to execute actions in automated way please install required modules. Those modules will be installed straight from Microsoft PowerShell Gallery." + New-HTMLCodeBlock -Code { + Install-Module GPOZaurr -Force + Import-Module GPOZaurr -Force + } -Style powershell + New-HTMLText -Text "Using force makes sure newest version is downloaded from PowerShellGallery regardless of what is currently installed. Once installed you're ready for next step." + } + New-HTMLWizardStep -Name 'Prepare report' { + New-HTMLText -Text "Depending when this report was run you may want to prepare new report before proceeding with removal. To generate new report please use:" + New-HTMLCodeBlock -Code { + Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrBrokenGpoBefore.html -Verbose -Type GPOOrphans + } + New-HTMLText -TextBlock { + "When executed it will take a while to generate all data and provide you with new report depending on size of environment." + "Once confirmed that data is still showing issues and requires fixing please proceed with next step." + } + New-HTMLText -Text "Alternatively if you prefer working with console you can run: " + New-HTMLCodeBlock -Code { + $GPOOutput = Get-GPOZaurrBroken + $GPOOutput | Format-Table + } + New-HTMLText -Text "It provides same data as you see in table above just doesn't prettify it for you." + } + New-HTMLWizardStep -Name 'Fix GPOs not available on SYSVOL' { + New-HTMLText -Text "Following command when executed runs cleanup procedure that removes all broken GPOs on SYSVOL side." + New-HTMLText -Text "Make sure when running it for the first time to run it with ", "WhatIf", " parameter as shown below to prevent accidental removal." -FontWeight normal, bold, normal -Color Black, Red, Black + + New-HTMLCodeBlock -Code { + Remove-GPOZaurrBroken -Type SYSVOL -WhatIf + } + New-HTMLText -TextBlock { + "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " + } + New-HTMLCodeBlock -Code { + Remove-GPOZaurrBroken -Type SYSVOL -LimitProcessing 2 -BackupPath $Env:UserProfile\Desktop\GPOSYSVOLBackup + } + New-HTMLText -TextBlock { + "This command when executed deletes only first X broken GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." + "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." + } + New-HTMLText -Text "If there's nothing else to be deleted on SYSVOL side, we can skip to next step step" + } + New-HTMLWizardStep -Name 'Fix GPOs not available on AD' { + New-HTMLText -Text "Following command when executed runs cleanup procedure that removes all broken GPOs on Active Directory side." + New-HTMLText -Text "Make sure when running it for the first time to run it with ", "WhatIf", " parameter as shown below to prevent accidental removal." -FontWeight normal, bold, normal -Color Black, Red, Black + + New-HTMLCodeBlock -Code { + Remove-GPOZaurrBroken -Type AD -WhatIf + } + New-HTMLText -TextBlock { + "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " + } + New-HTMLCodeBlock -Code { + Remove-GPOZaurrBroken -Type AD -LimitProcessing 2 -BackupPath $Env:UserProfile\Desktop\GPOSYSVOLBackup + } + New-HTMLText -TextBlock { + "This command when executed deletes only first X broken GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." + "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." + } + New-HTMLText -Text "If there's nothing else to be deleted on AD side, we can skip to next step step" + } + New-HTMLWizardStep -Name 'Verification report' { + New-HTMLText -TextBlock { + "Once cleanup task was executed properly, we need to verify that report now shows no problems." + } + New-HTMLCodeBlock -Code { + Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrBrokenGpoAfter.html -Verbose -Type GPOOrphans + } + New-HTMLText -Text "If everything is healthy in the report you're done! Enjoy rest of the day!" -Color BlueDiamond + } + } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center + } + } + } + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrPermissions.ps1 b/Private/Invoke.GPOZaurrPermissions.ps1 new file mode 100644 index 0000000..48b156e --- /dev/null +++ b/Private/Invoke.GPOZaurrPermissions.ps1 @@ -0,0 +1,18 @@ +$GPOZaurrPermissions = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + + } + Solution = { + + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrPermissionsRoot.ps1 b/Private/Invoke.GPOZaurrPermissionsRoot.ps1 new file mode 100644 index 0000000..ecd8037 --- /dev/null +++ b/Private/Invoke.GPOZaurrPermissionsRoot.ps1 @@ -0,0 +1,18 @@ +$GPOZaurrPermissionsRoot = [ordered] @{ + Name = 'GPO Permissions Consistency' + Enabled = $true + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + + } + Solution = { + New-HTMLTable -DataTable $GPOPermissionsRoot -Filtering + } +} \ No newline at end of file diff --git a/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 b/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 new file mode 100644 index 0000000..4f0dd77 --- /dev/null +++ b/Private/Invoke.GPOZaurrSysVolLegacyFiles.ps1 @@ -0,0 +1,18 @@ +$GPOZaurrSysVolLegacyFiles = [ordered] @{ + Name = 'SYSVOL Legacy ADM Files' + Enabled = $false + Data = $null + Execute = { } + Processing = { + + } + Variables = @{ + + } + Overview = { + + } + Solution = { + + } +} \ No newline at end of file diff --git a/Private/Script.GPOConfiguration.ps1 b/Private/Script.GPOConfiguration.ps1 index a9f8c5b..56eb300 100644 --- a/Private/Script.GPOConfiguration.ps1 +++ b/Private/Script.GPOConfiguration.ps1 @@ -1,154 +1,12 @@ -<# -$Script:GPOConfiguration = [ordered] @{ - GPOOrphans = [ordered] @{ - Wizard = { - New-HTMLWizardStep -Name 'Prepare environment' { - New-HTMLText -Text "To be able to execute actions in automated way please install required modules. Those modules will be installed straight from Microsoft PowerShell Gallery." - New-HTMLCodeBlock -Code { - Install-Module GPOZaurr -Force - Import-Module GPOZaurr -Force - } -Style powershell - New-HTMLText -Text "Using force makes sure newest version is downloaded from PowerShellGallery regardless of what is currently installed. Once installed you're ready for next step." - } - New-HTMLWizardStep -Name 'Prepare report' { - New-HTMLText -Text "Depending when this report was run you may want to prepare new report before proceeding with removal. To generate new report please use:" - New-HTMLCodeBlock -Code { - Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrBrokenGpoBefore.html -Verbose -Type GPOOrphans - } - New-HTMLText -TextBlock { - "When executed it will take a while to generate all data and provide you with new report depending on size of environment." - "Once confirmed that data is still showing issues and requires fixing please proceed with next step." - } - New-HTMLText -Text "Alternatively if you prefer working with console you can run: " - New-HTMLCodeBlock -Code { - $GPOOutput = Get-GPOZaurrBroken - $GPOOutput | Format-Table - } - New-HTMLText -Text "It provides same data as you see in table above just doesn't prettify it for you." - } - New-HTMLWizardStep -Name 'Fix GPOs not available on SYSVOL' { - New-HTMLText -Text "Following command when executed runs cleanup procedure that removes all broken GPOs on SYSVOL side." - New-HTMLText -Text "Make sure when running it for the first time to run it with ", "WhatIf", " parameter as shown below to prevent accidental removal." -FontWeight normal, bold, normal -Color Black, Red, Black - - New-HTMLCodeBlock -Code { - Remove-GPOZaurrBroken -Type SYSVOL -WhatIf - } - New-HTMLText -TextBlock { - "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " - } - New-HTMLCodeBlock -Code { - Remove-GPOZaurrBroken -Type SYSVOL -LimitProcessing 2 -BackupPath $Env:UserProfile\Desktop\GPOSYSVOLBackup - } - New-HTMLText -TextBlock { - "This command when executed deletes only first X broken GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." - "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." - } - New-HTMLText -Text "If there's nothing else to be deleted on SYSVOL side, we can skip to next step step" - } - New-HTMLWizardStep -Name 'Fix GPOs not available on AD' { - New-HTMLText -Text "Following command when executed runs cleanup procedure that removes all broken GPOs on Active Directory side." - New-HTMLText -Text "Make sure when running it for the first time to run it with ", "WhatIf", " parameter as shown below to prevent accidental removal." -FontWeight normal, bold, normal -Color Black, Red, Black - - New-HTMLCodeBlock -Code { - Remove-GPOZaurrBroken -Type AD -WhatIf - } - New-HTMLText -TextBlock { - "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " - } - New-HTMLCodeBlock -Code { - Remove-GPOZaurrBroken -Type AD -LimitProcessing 2 -BackupPath $Env:UserProfile\Desktop\GPOSYSVOLBackup - } - New-HTMLText -TextBlock { - "This command when executed deletes only first X broken GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." - "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." - } - New-HTMLText -Text "If there's nothing else to be deleted on AD side, we can skip to next step step" - } - New-HTMLWizardStep -Name 'Verification report' { - New-HTMLText -TextBlock { - "Once cleanup task was executed properly, we need to verify that report now shows no problems." - } - New-HTMLCodeBlock -Code { - Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrBrokenGpoAfter.html -Verbose -Type GPOOrphans - } - New-HTMLText -Text "If everything is healthy in the report you're done! Enjoy rest of the day!" -Color BlueDiamond - } - } - } - GPOList = [ordered] @{ - List = { - - } - Wizard = { - New-HTMLWizardStep -Name 'Prepare environment' { - New-HTMLText -Text "To be able to execute actions in automated way please install required modules. Those modules will be installed straight from Microsoft PowerShell Gallery." - New-HTMLCodeBlock -Code { - Install-Module GPOZaurr -Force - Import-Module GPOZaurr -Force - } -Style powershell - New-HTMLText -Text "Using force makes sure newest version is downloaded from PowerShellGallery regardless of what is currently installed. Once installed you're ready for next step." - } - New-HTMLWizardStep -Name 'Prepare report' { - New-HTMLText -Text "Depending when this report was run you may want to prepare new report before proceeding with removal. To generate new report please use:" - New-HTMLCodeBlock -Code { - Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrEmptyUnlinked.html -Verbose -Type GPOList - } - New-HTMLText -TextBlock { - "When executed it will take a while to generate all data and provide you with new report depending on size of environment." - "Once confirmed that data is still showing issues and requires fixing please proceed with next step." - } - New-HTMLText -Text "Alternatively if you prefer working with console you can run: " - New-HTMLCodeBlock -Code { - $GPOOutput = Get-GPOZaurr - $GPOOutput | Format-Table - } - New-HTMLText -Text "It provides same data as you see in table above just doesn't prettify it for you." - } - New-HTMLWizardStep -Name 'Remove GPOs that are EMPTY or UNLINKED' { - New-HTMLText -Text @( - "Following command when executed removes every ", - "EMPTY" - " or " - "NOT LINKED" - " Group Policy. Make sure when running it for the first time to run it with ", - "WhatIf", - " parameter as shown below to prevent accidental removal.", - "Make sure to use BackupPath which will make sure that for each GPO that is about to be deleted a backup is made to folder on a desktop." - ) -FontWeight normal, bold, normal, bold, normal, bold, normal, normal -Color Black, Red, Black, Red, Black - New-HTMLCodeBlock -Code { - Remove-GPOZaurr -Type Empty, Unlinked -BackupPath "$Env:UserProfile\Desktop\GPO" -Verbose -WhatIf - } - New-HTMLText -TextBlock { - "After execution please make sure there are no errors, make sure to review provided output, and confirm that what is about to be deleted matches expected data. Once happy with results please follow with command: " - } - New-HTMLCodeBlock -Code { - Remove-GPOZaurr -Type Empty, Unlinked -BackupPath "$Env:UserProfile\Desktop\GPO" -LimitProcessing 2 -Verbose - } - New-HTMLText -TextBlock { - "This command when executed deletes only first empty or unlinked GPOs. Use LimitProcessing parameter to prevent mass delete and increase the counter when no errors occur." - "Repeat step above as much as needed increasing LimitProcessing count till there's nothing left. In case of any issues please review and action accordingly." - "Please make sure to check if backup is made as well before going all in." - } - New-HTMLText -Text "If there's nothing else to be deleted on SYSVOL side, we can skip to next step step" - } - New-HTMLWizardStep -Name 'Verification report' { - New-HTMLText -TextBlock { - "Once cleanup task was executed properly, we need to verify that report now shows no problems." - } - New-HTMLCodeBlock -Code { - Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrEmptyUnlinkedAfter.html -Verbose -Type GPOList - } - New-HTMLText -Text "If there are no more empty or unlinked GPOs in the report you're done! Enjoy rest of the day!" -Color BlueDiamond - } - } - } - GPOConsistency = $ScriptGPOConfigurationGPOConsistency - NetLogon = $ScriptGPOConfigurationNetLogon - GPOOwners = $ScriptGPOConfigurationGPOOwners -} -#> - -$Script:GPOConfiguration = @{ - GPOConsistency = $GPOZaurrConsistency - GPOOwners = $GPOZaurrOwners +$Script:GPOConfiguration = @{ + GPOConsistency = $GPOZaurrConsistency + GPOOwners = $GPOZaurrOwners + GPOList = $GPOZaurrList + GPOOrphans = $GPOZaurrOrphans + GPOPermissions = $GPOZaurrPermissions + GPOPermissionsRoot = $GPOZaurrPermissionsRoot + GPOFiles = $GPOZaurrFiles + GPOAnalysis = $GPOZaurrAnalysis + NetLogonPermissions = $GPOZaurrNetLogonPermissions + SysVolLegacyFiles = $GPOZaurrSysVolLegacyFiles } \ No newline at end of file diff --git a/Public/Invoke-GPOZaurr.ps1 b/Public/Invoke-GPOZaurr.ps1 index 4eee645..943940b 100644 --- a/Public/Invoke-GPOZaurr.ps1 +++ b/Public/Invoke-GPOZaurr.ps1 @@ -57,56 +57,6 @@ <# # Gather data $TimeLog = Start-TimeLog - if ($Type -contains 'GPOList' -or $null -eq $Type) { - $TimeLogGPOList = Start-TimeLog - Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO List" - $GPOSummary = Get-GPOZaurr - $GPONotLinked = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOLinked = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPONotEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOEmptyAndUnlinked = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOEmptyOrUnlinked = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOLinkedButEmpty = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOValid = [System.Collections.Generic.List[PSCustomObject]]::new() - $GPOLinkedButLinkDisabled = [System.Collections.Generic.List[PSCustomObject]]::new() - foreach ($GPO in $GPOSummary) { - if ($GPO.Linked -eq $false -and $GPO.Empty -eq $true) { - # Not linked, Empty - $GPOEmptyAndUnlinked.Add($GPO) - $GPOEmptyOrUnlinked.Add($GPO) - $GPONotLinked.Add($GPO) - $GPOEmpty.Add($GPO) - } elseif ($GPO.Linked -eq $true -and $GPO.Empty -eq $true) { - # Linked, But EMPTY - $GPOLinkedButEmpty.Add($GPO) - $GPOEmptyOrUnlinked.Add($GPO) - $GPOEmpty.Add($GPO) - $GPOLinked.Add($GPO) - } elseif ($GPO.Linked -eq $false) { - # Not linked, but not EMPTY - $GPONotLinked.Add($GPO) - $GPOEmptyOrUnlinked.Add($GPO) - $GPONotEmpty.Add($GPO) - } elseif ($GPO.Empty -eq $true) { - # Linked, But EMPTY - $GPOEmpty.Add($GPO) - $GPOEmptyOrUnlinked.Add($GPO) - $GPOLinked.Add($GPO) - } else { - # Linked, not EMPTY - $GPOValid.Add($GPO) - $GPOLinked.Add($GPO) - $GPONotEmpty.Add($GPO) - } - if ($GPO.LinksDisabledCount -eq $GPO.LinksCount -and $GPO.LinksCount -gt 0) { - $GPOLinkedButLinkDisabled.Add($GPO) - } - } - $GPOTotal = $GPOSummary.Count - $TimeEndGPOList = Stop-TimeLog -Time $TimeLogGPOList -Option OneLiner - Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO List $TimeEndGPOList" - } if ($Type -contains 'GPOOrphans' -or $null -eq $Type) { #Write-Color -Text "[Info] ", "Processing GPOOrphans" -Color Yellow, White Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO Sysvol" @@ -130,23 +80,10 @@ Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO Permissions" $GPOPermissions = Get-GPOZaurrPermission -Type All -IncludePermissionType GpoEditDeleteModifySecurity, GpoEdit, GpoCustom -IncludeOwner } - if ($Type -contains 'GPOConsistency' -or $null -eq $Type) { - Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO Permissions Consistency" - $Script:GPOZaurrConsistency['Data'] = & $Script:GPOZaurrConsistency['Execute'] - & $Script:GPOZaurrConsistency['Processing'] - } if ($Type -contains 'GPOPermissionsRoot' -or $null -eq $Type) { Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO Permissions Root" $GPOPermissionsRoot = Get-GPOZaurrPermissionRoot -SkipNames } - if ($Type -contains 'GPOOwners' -or $null -eq $Type) { - $TimeLogGPOList = Start-TimeLog - Write-Verbose "Invoke-GPOZaurr - Processing GPO Owners" - $Script:GpoZaurrOwners['Data'] = & $Script:GpoZaurrOwners['Execute'] - & $Script:GpoZaurrOwners['Processing'] - $TimeEndGPOList = Stop-TimeLog -Time $TimeLogGPOList -Option OneLiner - Write-Verbose -Message "Invoke-GPOZaurr - Processing GPO Owners $TimeEndGPOList" - } if ($Type -contains 'NetLogon' -or $null -eq $Type) { $TimeLogSection = Start-TimeLog Write-Verbose "Get-GPOZaurrNetLogon - Processing NETLOGON Share" @@ -225,287 +162,7 @@ } } } else { - New-HTMLTab -Name 'Overview' { - if ($Type -contains 'GPOConsistency' -or $Type -contains 'GPOList' -or $null -eq $Type) { - New-HTMLSection -Invisible { - if ($Type -contains 'GPOList' -or $null -eq $Type) { - New-HTMLPanel { - New-HTMLText -Text 'Following chart presents ', 'Linked / Empty and Unlinked Group Policies' -FontSize 10pt -FontWeight normal, bold - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies total: ', $GPOTotal -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies valid: ", $GPOValid.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies to delete: ", $GPOEmptyOrUnlinked.Count -FontWeight normal, bold { - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPONotLinked.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOEmpty.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOLinkedButEmpty.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOLinkedButLinkDisabled.Count -FontWeight normal, bold - } - } - } -FontSize 10pt - New-HTMLText -FontSize 10pt -Text 'Usually empty or unlinked Group Policies are safe to delete.' - New-HTMLChart -Title 'Group Policies Summary' { - New-ChartBarOptions -Type barStacked - #New-ChartLegend -Names 'Unlinked', 'Linked', 'Empty', 'Total' -Color Salmon, PaleGreen, PaleVioletRed, PaleTurquoise - New-ChartLegend -Names 'Good', 'Bad' -Color PaleGreen, Salmon - #New-ChartBar -Name 'Group Policies' -Value $GPONotLinked.Count, $GPOLinked.Count, $GPOEmpty.Count, $GPOTotal - New-ChartBar -Name 'Linked' -Value $GPOLinked.Count, $GPONotLinked.Count - New-ChartBar -Name 'Empty' -Value $GPONotEmpty.Count, $GPOEmpty.Count - New-ChartBar -Name 'Valid' -Value $GPOValid.Count, $GPOEmptyOrUnlinked.Count - } -TitleAlignment center - } - - } - if ($Type -contains 'GPOConsistency' -or $null -eq $Type) { - if ($Script:GPOZaurrConsistency['Overview']) { - & $Script:GPOZaurrConsistency['Overview'] - } - } - } - } - if ($Type -contains 'GPOOwners' -or $Type -contains 'GPOOrphans' -or $null -eq $Type) { - New-HTMLSection -Invisible { - if ($Type -contains 'GPOOwners' -or $null -eq $Type) { - if ($Script:GpoZaurrOwners['Overview']) { - & $Script:GpoZaurrOwners['Overview'] - } - } - if ($Type -contains 'GPOOrphans' -or $null -eq $Type) { - New-HTMLPanel { - New-HTMLText -Text 'Following chart presents ', 'Broken / Orphaned Group Policies' -FontSize 10pt -FontWeight normal, bold - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies on SYSVOL, but no details in AD: ', $NotAvailableInAD.Count -FontWeight normal, bold - New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $NotAvailableOnSysvol.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $NotAvailablePermissionIssue.Count -FontWeight normal, bold - } -FontSize 10pt - New-HTMLText -FontSize 10pt -Text 'Those problems must be resolved before doing other clenaup activities.' - New-HTMLChart { - New-ChartBarOptions -Type barStacked - New-ChartLegend -Name 'Not in AD', 'Not on SYSVOL', 'Permissions Issue' -Color Crimson, LightCoral, IndianRed - New-ChartBar -Name 'Orphans' -Value $NotAvailableInAD.Count, $NotAvailableOnSysvol.Count, $NotAvailablePermissionIssue.Count - } -Title 'Broken / Orphaned Group Policies' -TitleAlignment center - } - } - } - } - if ($Type -contains 'NetLogon' -or $null -eq $Type) { - New-HTMLSection -Invisible { - New-HTMLPanel { - New-HTMLText -Text 'Following chart presents ', 'NetLogon Summary' -FontSize 10pt -FontWeight normal, bold - New-HTMLList -Type Unordered { - & $Script:GPOConfiguration['NetLogon']['List'] - } -FontSize 10pt - #New-HTMLText -FontSize 10pt -Text 'Those problems must be resolved before doing other clenaup activities.' - New-HTMLChart { - New-ChartPie -Name 'Correct Owners' -Value $NetLogonOwnersAdministrators.Count -Color LightGreen - New-ChartPie -Name 'Incorrect Owners' -Value $NetLogonOwnersToFix.Count -Color Crimson - } -Title 'NetLogon Owners' -TitleAlignment center - } - New-HTMLPanel { - - } - } - } - } - - if ($Type -contains 'GPOList' -or $null -eq $Type) { - New-HTMLTab -Name 'Group Policies Summary' { - New-HTMLPanel { - $newHTMLTextSplat = @{ - Text = @( - 'Following table shows a list of group policies.', - 'By using following table you can easily find which GPOs can be safely deleted because those are empty or unlinked or linked, but link disabled.' - ) - FontSize = '10pt' - FontWeight = 'normal', 'bold' - } - New-HTMLText @newHTMLTextSplat - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies total: ', $GPOTotal -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies valid: ", $GPOValid.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies to delete: ", $GPOEmptyOrUnlinked.Count -FontWeight normal, bold { - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPONotLinked.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOEmpty.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOLinkedButEmpty.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOLinkedButLinkDisabled.Count -FontWeight normal, bold - } - } - } -FontSize 10pt - New-HTMLText -Text 'All those mentioned Group Policies can be automatically deleted following the steps below the table.' -FontSize 10pt - } - New-HTMLSection -Name 'Group Policies List' { - New-HTMLTable -DataTable $GPOSummary -Filtering { - New-HTMLTableCondition -Name 'Empty' -Value $true -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string - New-HTMLTableCondition -Name 'Linked' -Value $false -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string - } -PagingOptions 10, 20, 30, 40, 50 - } - New-HTMLSection -Name 'Steps to fix - Empty & Unlinked Group Policies' { - New-HTMLContainer { - New-HTMLSpanStyle -FontSize 10pt { - New-HTMLText -Text 'Following steps will guide you how to remove empty or unlinked group policies' - New-HTMLWizard { - & $Script:GPOConfiguration['GPOList']['Wizard'] - } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center - } - } - } - } - } - if ($Type -contains 'GPOOrphans' -or $null -eq $Type) { - New-HTMLTab -Name 'Health State' { - New-HTMLPanel { - New-HTMLText -TextBlock { - "Following table shows list of all group policies and their status in AD and SYSVOL. Due to different reasons it's " - "possible that " - } -FontSize 10pt - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Group Policies on SYSVOL, but no details in AD: ', $NotAvailableInAD.Count -FontWeight normal, bold - New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $NotAvailableOnSysvol.Count -FontWeight normal, bold - New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $NotAvailablePermissionIssue.Count -FontWeight normal, bold - } -FontSize 10pt - New-HTMLText -Text "Follow the steps below table to get Active Directory Group Policies in healthy state." -FontSize 10pt - } - New-HTMLSection -Name 'Health State of Group Policies' { - New-HTMLTable -DataTable $GPOOrphans -Filtering { - New-HTMLTableCondition -Name 'Status' -Value "Not available in AD" -BackgroundColor Salmon -ComparisonType string - New-HTMLTableCondition -Name 'Status' -Value "Not available on SYSVOL" -BackgroundColor LightCoral -ComparisonType string - New-HTMLTableCondition -Name 'Status' -Value "Permissions issue" -BackgroundColor MediumVioletRed -ComparisonType string -Color White - } -PagingOptions 10, 20, 30, 40, 50 - } - New-HTMLSection -Name 'Steps to fix - Not available on SYSVOL / Active Directory' { - New-HTMLContainer { - New-HTMLSpanStyle -FontSize 10pt { - New-HTMLText -Text 'Following steps will guide you how to fix GPOs which are not available on SYSVOL or AD.' - New-HTMLWizard { - & $Script:GPOConfiguration['GPOOrphans']['Wizard'] - } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center - } - } - } - } - } - if ($Type -contains 'NetLogon' -or $Type -contains 'GPOFiles' -or $null -eq $Type) { - New-HTMLTab -Name 'Files (SysVol / NetLogon)' { - if ($Type -contains 'NetLogon' -or $null -eq $Type) { - New-HTMLTab -Name 'NetLogon Owners' { - New-HTMLPanel { - New-HTMLText -TextBlock { - "Following table shows NetLogon file owners. It's important that NetLogon file owners are set to BUILTIN\Administrators (SID: S-1-5-32-544). " - "Owners have full control over the file object. Current owner of the file may be an Administrator but it doesn't guarentee that he will be in the future. " - "That's why as a best-practice it's recommended to change any non-administrative owners to BUILTIN\Administrators, and even Administrative accounts should be replaced with it. " - } -FontSize 10pt - New-HTMLList -Type Unordered { - & $Script:GPOConfiguration['NetLogon']['List'] - } -FontSize 10pt - New-HTMLText -Text "Follow the steps below table to get NetLogon Owners into compliant state." -FontSize 10pt - } - New-HTMLSection -Name 'NetLogon Files List' { - New-HTMLTable -DataTable $NetLogonOwners -Filtering { - New-HTMLTableCondition -Name 'PrincipalSid' -Value "S-1-5-32-544" -BackgroundColor LightGreen -ComparisonType string - New-HTMLTableCondition -Name 'PrincipalSid' -Value "S-1-5-32-544" -BackgroundColor Salmon -ComparisonType string -Operator ne - New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq - } - } - New-HTMLSection -Name 'Steps to fix NetLogon Owners ' { - New-HTMLContainer { - New-HTMLSpanStyle -FontSize 10pt { - New-HTMLText -Text 'Following steps will guide you how to fix NetLogon Owners and make them compliant.' - New-HTMLWizard { - & $Script:GPOConfiguration['NetLogon']['Wizard'] - } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center - } - } - } - - } - New-HTMLTab -Name 'NetLogon Permissions' { - New-HTMLSection -Name 'NetLogon Files List' { - New-HTMLTable -DataTable $Netlogon -Filtering - } - } - } - if ($Type -contains 'GPOFiles' -or $null -eq $Type) { - New-HTMLTab -Name 'SysVol Files Assesment' { - New-HTMLTable -DataTable $GPOFiles -Filtering - } - } - } - } - if ($Type -contains 'GPOPermissionsRoot' -or $Type -contains 'GPOOwners' -or - $Type -contains 'GPOPermissions' -or $Type -contains 'GPOConsistency' -or - $null -eq $Type - ) { - New-HTMLTab -Name 'Permissions' { - if ($Type -contains 'GPOPermissionsRoot' -or $null -eq $Type) { - New-HTMLTab -Name 'Root' { - New-HTMLTable -DataTable $GPOPermissionsRoot -Filtering - } - } - if ($Type -contains 'GPOOwners' -or $null -eq $Type) { - New-HTMLTab -Name 'Owners' { - if ($Script:GpoZaurrOwners['Solution']) { - & $Script:GpoZaurrOwners['Solution'] - } - } - } - if ($Type -contains 'GPOPermissions' -or $null -eq $Type) { - New-HTMLTab -Name 'Edit & Modify' { - New-HTMLTable -DataTable $GPOPermissions -Filtering - } - } - if ($Type -contains 'GPOConsistency' -or $null -eq $Type) { - New-HTMLTab -Name 'Permissions Consistency' { - if ($Script:GPOZaurrConsistency['Solution']) { - & $Script:GPOZaurrConsistency['Solution'] - } - <# - New-HTMLPanel { - New-HTMLText -Text 'Following table presents ', 'permissions consistency between Active Directory and SYSVOL for Group Policies' -FontSize 10pt -FontWeight normal, bold - New-HTMLList -Type Unordered { - New-HTMLListItem -Text 'Top level permissions consistency: ', $Inconsistent[0].Count -FontWeight normal, bold - New-HTMLListItem -Text 'Inherited permissions consistency: ', $InconsistentInside[0].Count -FontWeight normal, bold - New-HTMLListItem -Text 'Inconsistent top level permissions: ', $Inconsistent[1].Count -FontWeight normal, bold - New-HTMLListItem -Text "Inconsistent inherited permissions: ", $InconsistentInside[1].Count -FontWeight normal, bold - } -FontSize 10pt - New-HTMLText -FontSize 10pt -Text 'Having incosistent permissions on AD in comparison to those on SYSVOL can lead to uncontrolled ability to modify them. Please notice that if ', ` - ' Not available ', 'is visible in the table you should first fix related, more pressing issue, before fixing permissions inconsistency.' -FontWeight normal, bold, normal - } - New-HTMLSection -Name 'Group Policy Permissions Consistency' { - New-HTMLTable -DataTable $GPOPermissionsConsistency -Filtering { - New-HTMLTableCondition -Name 'ACLConsistent' -Value $false -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string - New-HTMLTableCondition -Name 'ACLConsistentInside' -Value $false -BackgroundColor Salmon -TextTransform capitalize -ComparisonType string - New-HTMLTableCondition -Name 'ACLConsistent' -Value $true -BackgroundColor PaleGreen -TextTransform capitalize -ComparisonType string - New-HTMLTableCondition -Name 'ACLConsistentInside' -Value $true -BackgroundColor PaleGreen -TextTransform capitalize -ComparisonType string - New-HTMLTableCondition -Name 'ACLConsistent' -Value 'Not available' -BackgroundColor Crimson -ComparisonType string - New-HTMLTableCondition -Name 'ACLConsistentInside' -Value 'Not available' -BackgroundColor Crimson -ComparisonType string - } -PagingOptions 10, 20, 30, 40, 50 - } - New-HTMLSection -Name 'Steps to fix - Permissions Consistency' { - New-HTMLContainer { - New-HTMLSpanStyle -FontSize 10pt { - New-HTMLText -Text 'Following steps will guide you how to fix permissions consistency' - New-HTMLWizard { - & $Script:GPOConfiguration['GPOConsistency']['Wizard'] - } -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center - } - } - } - #> - } - } - } - } - if ($Type -contains 'GPOAnalysis' -or $null -eq $Type) { - New-HTMLTab -Name 'Analysis' { - foreach ($Key in $GPOContent.Keys) { - New-HTMLTab -Name $Key { - New-HTMLTable -DataTable $GPOContent[$Key] -Filtering -Title $Key - } - } - } - } } } -Online -ShowHTML -FilePath $FilePath