Compare commits

...

47 Commits

Author SHA1 Message Date
Przemyslaw Klys 64bc1ff092 Update readme 2020-11-06 11:17:56 +01:00
Przemyslaw Klys 6f92043c3a Update 2020-11-06 11:17:01 +01:00
Przemyslaw Klys 7ce5027abd Update 2020-11-06 10:35:11 +01:00
Przemyslaw Klys 0c8e23f6af Update 2020-11-05 23:36:24 +01:00
Przemyslaw Klys 731ba420b9 Update 2020-11-05 22:46:10 +01:00
Przemyslaw Klys 8790be18bb Update 2020-11-05 21:32:31 +01:00
Przemyslaw Klys e495411714 Update 2020-11-05 19:44:48 +01:00
Przemyslaw Klys fab33b8d14 Update 2020-11-05 19:21:00 +01:00
Przemyslaw Klys e00c93b798 Update 2020-11-05 18:28:51 +01:00
Przemyslaw Klys ee5e03d666 Update 2020-11-05 18:06:49 +01:00
Przemyslaw Klys ad2067c714 Update 2020-11-05 16:36:48 +01:00
Przemyslaw Klys b5e4fd07dc Update 2020-11-05 11:28:58 +01:00
Przemyslaw Klys 981e71483a Update 2020-11-04 20:55:47 +01:00
Przemyslaw Klys 26e9486894 Update psd1 2020-11-03 09:06:15 +01:00
Przemyslaw Klys 2f874b8dc8 Update 2020-10-29 20:24:26 +01:00
Przemyslaw Klys f1e211e560 Update readme 2020-10-29 18:48:43 +01:00
Przemyslaw Klys 4d82b51577 Update 2020-10-29 18:47:13 +01:00
Przemyslaw Klys ee9effa4f1 Update examples 2020-10-29 11:35:33 +01:00
Przemyslaw Klys af673cef1c Update readme 2020-10-29 11:34:16 +01:00
Przemyslaw Klys 38bf93fef3 Update 2020-10-29 11:32:25 +01:00
Przemyslaw Klys 3811bf68ad Update 2020-10-28 18:25:39 +01:00
Przemyslaw Klys e5d897d354 Update 2020-10-28 18:25:21 +01:00
Przemyslaw Klys 901be9fc66 Update PSD1 2020-10-28 11:40:35 +01:00
Przemyslaw Klys 57f9d02635 Update 2020-10-28 11:40:22 +01:00
Przemyslaw Klys d7e1ccd2f2 Update 2020-10-28 11:37:38 +01:00
Przemyslaw Klys 8d7ef2512d Update 2020-10-27 11:09:06 +01:00
Przemyslaw Klys ed417e7d9e Update 2020-10-24 20:30:35 +02:00
Przemyslaw Klys df07cc5a6b Update 2020-10-24 20:29:34 +02:00
Przemyslaw Klys 68f7a9292c Update 2020-10-23 18:53:47 +02:00
Przemyslaw Klys dc53cb36e0 Update readme 2020-10-22 14:55:25 +02:00
Przemyslaw Klys 7ff834fbfa Update 2020-10-22 14:55:04 +02:00
Przemyslaw Klys f5cf5dac4d Update 2020-10-22 14:00:46 +02:00
Przemyslaw Klys 5ffe89dec3 Update 2020-10-22 14:00:15 +02:00
Przemyslaw Klys 191b709ccf Update 2020-10-22 13:42:27 +02:00
Przemyslaw Klys b3e15d66ea Update 2020-10-22 10:51:37 +02:00
Przemyslaw Klys b3751d1dcc Update 2020-10-22 09:17:01 +02:00
Przemyslaw Klys 928d66eb9d Update 2020-10-22 09:16:07 +02:00
Przemyslaw Klys 72ecf97497 new release 2020-10-21 13:17:37 +02:00
Przemyslaw Klys aa8773ce73 Update 2020-10-21 12:48:37 +02:00
Przemyslaw Klys 6f11155914 Update 2020-10-20 22:49:22 +02:00
Przemyslaw Klys fd5413164a Update 2020-10-20 21:02:54 +02:00
Przemyslaw Klys 295f2e0a48 Update 2020-10-19 10:41:39 +02:00
Przemyslaw Klys 13e5672b3f Update 2020-10-19 10:38:55 +02:00
Przemyslaw Klys a0723227c0 Update share permissions 2020-10-19 00:06:02 +02:00
Przemyslaw Klys 72b2d2482b update functions 2020-10-19 00:05:50 +02:00
Przemyslaw Klys 0c12761601 Update 2020-10-18 20:17:06 +02:00
Przemyslaw Klys 4ca5c8f1e7 Update 2020-10-17 09:28:58 +02:00
47 changed files with 1672 additions and 189 deletions
+2 -2
View File
@@ -2,8 +2,8 @@
# Backup GPOs
$BackupPath = "$Env:UserProfile\Desktop\GPO"
$GPOSummary = Backup-GPOZaurr -BackupPath $BackupPath -Verbose -Type Unlinked -BackupDated #-LimitProcessing 1
$GPOSummary = Backup-GPOZaurr -BackupPath $BackupPath -Verbose -Type All #-BackupDated #-LimitProcessing 1
$GPOSummary | Format-Table -AutoSize
# Confirm GPOs are backed up properly
## Confirm GPOs are backed up properly
Get-GPOZaurrBackupInformation -BackupFolder $GPOSummary[0].BackupDirectory | Format-Table -a
@@ -1,5 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
# Remove GPOS
$BackupPath = "$Env:UserProfile\Desktop\GPO"
Remove-GPOZaurr -Type Empty, Unlinked -BackupPath $BackupPath -BackupDated -LimitProcessing 2 -Verbose -WhatIf
Remove-GPOZaurr -Type Empty, Unlinked -BackupPath "$Env:UserProfile\Desktop\GPO" -BackupDated -LimitProcessing 2 -Verbose -WhatIf
+1 -1
View File
@@ -5,7 +5,7 @@ $Report = Get-GPOZaurrOwner -IncludeSysvol
$Report | ConvertTo-Excel -FilePath $Env:UserProfile\Desktop\GPOOwners.xlsx -ExcelWorkSheetName 'GPO Owners Before' -AutoFilter -AutoFit
# Step 2 - Fix owners / use WhatIf and LimitProcessing / verify changes before/after
Set-GPOZaurrOwner -Type NotAdministrative -Verbose -LimitProcessing 2 -WhatIf
Set-GPOZaurrOwner -Type All -Verbose:$true -WhatIf # -LimitProcessing 2
# Step 3
$Report = Get-GPOZaurrOwner -IncludeSysvol
+2 -2
View File
@@ -1,7 +1,7 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
#$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPODefender'
$Output = Invoke-GPOZaurr -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExport' -Type WindowsHelloForBusiness
#$Output = Invoke-GPOZaurrContent -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPODefender'
$Output = Invoke-GPOZaurrContent -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExport' -Type WindowsHelloForBusiness
$Output | Format-Table
$Output.WindowsDefenderExploitGuard | Format-Table
$Output.Reports.RegistrySetting | Format-Table
+1 -1
View File
@@ -2,7 +2,7 @@
# This gets the same thing as earlier examples
# with a difference where one entry per gpo and all settings for that GPO is stored under settings property.
$Output = Invoke-GPOZaurr -SingleObject -Verbose
$Output = Invoke-GPOZaurrContent -SingleObject -Verbose
$Output | Format-Table
$Output.Reports.RegistrySettings | Format-Table *
$Output.Reports.RegistrySettings[0].Settings | Format-Table *
+1 -1
View File
@@ -4,7 +4,7 @@
# This will allow you to process offline data more than once
# It's useful for when you want to request different types
$Output = Invoke-GPOZaurr -GPOPath $ENV:USERPROFILE\Desktop\GPOExportAudit -Extended -Verbose
$Output = Invoke-GPOZaurrContent -GPOPath $ENV:USERPROFILE\Desktop\GPOExportAudit -Extended -Verbose
$Output | Format-Table *
$Output.Reports | Format-Table
+1 -1
View File
@@ -1,4 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$Output = Invoke-GPOZaurr -Verbose #-SingleObject
$Output = Invoke-GPOZaurrContent -Verbose -OutputType HTML, Object -Open
$Output | Format-Table
@@ -1,9 +1,10 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
# Asses GPO based on exported data
$Output = Invoke-GPOZaurr -GPOPath $Env:USERPROFILE\Desktop\GPOExport_2020.10.12 -Verbose
$Output = Invoke-GPOZaurrContent -GPOPath $Env:USERPROFILE\Desktop\GPOExport_2020.10.12 -Verbose -Type RegistrySetting
$Output | Format-Table *
# Export to Excel
foreach ($Key in $Output.Keys) {
$Output[$Key] | ConvertTo-Excel -FilePath $Env:USERPROFILE\Desktop\EFGPOAnalysis.xlsx -ExcelWorkSheetName $Key -AutoFilter -AutoFit -FreezeTopRowFirstColumn
+1 -1
View File
@@ -1,4 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$Output = Invoke-GPOZaurr -GPOPath $ENV:USERPROFILE\Desktop\GPOTestingUserAccess -Verbose
$Output = Invoke-GPOZaurrContent -GPOPath $ENV:USERPROFILE\Desktop\GPOTestingUserAccess -Verbose
$Output | Format-Table *
+4
View File
@@ -0,0 +1,4 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
$FilesAll = Get-GPOZaurrNetlogon
$FilesAll | Format-Table -a *
+19
View File
@@ -0,0 +1,19 @@
#Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type NetLogon, GPOOrphans, GPOList, GPOConsistency
# Working conditions
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurrOrphans.html -Verbose -Type GPOOrphans
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurrEmptyUnlinked.html -Verbose -Type GPOList
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurrEmptyUnlinked.html -Verbose -Type GPOConsistency
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type NetLogon
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOOwners
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOPermissionsRoot
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOOrphans, GPOConsistency, GPOList, GPOPermissionsRoot, NetLogon, GPOFiles
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOConsistency
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOOrphans, GPOConsistency
#Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type GPOList
#Optimize-HTML -File 'C:\Support\GitHub\GpoZaurr\Examples\Reports\GPOZaurr.html' -OutputFile 'C:\Support\GitHub\GpoZaurr\Examples\Reports\GPOZaurr-Minified.html'
+1
View File
@@ -0,0 +1 @@
Invoke-GPOZaurr -FilePath $PSScriptRoot\Reports\GPOZaurr.html -Verbose -Type NetLogon, GPOOrphans, GPOList, GPOConsistency,GPOOwners
@@ -0,0 +1,3 @@
Import-Module "$PSScriptRoot\..\GPoZaurr.psd1" -Force
Repair-GPOZaurrNetLogonOwner -WhatIf:$true -Verbose -IncludeDomains ad.evotec.pl
+8 -8
View File
@@ -1,34 +1,34 @@
@{
AliasesToExport = @('Get-GPOZaurrFilesPolicyDefinitions', 'Find-GPO')
AliasesToExport = @('Get-GPOZaurrSysvol', 'Get-GPOZaurrFilesPolicyDefinitions', 'Show-GPOZaurr', 'Show-GPO', 'Find-GPO', 'Remove-GPOZaurrOrphaned')
Author = 'Przemyslaw Klys'
CmdletsToExport = @()
CompanyName = 'Evotec'
CompatiblePSEditions = @('Desktop')
Copyright = '(c) 2011 - 2020 Przemyslaw Klys @ Evotec. All rights reserved.'
Description = 'Group Policy Eater is a PowerShell module that aims to gather information about Group Policies but also allows fixing issues that you may find in them.'
FunctionsToExport = @('Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Clear-GPOZaurrSysvolDFSR', 'ConvertFrom-CSExtension', 'Find-CSExtension', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrDictionary', 'Get-GPOZaurrFiles', 'Get-GPOZaurrFilesPolicyDefinition', 'Get-GPOZaurrFolders', 'Get-GPOZaurrInheritance', 'Get-GPOZaurrLegacyFiles', 'Get-GPOZaurrLink', 'Get-GPOZaurrLinkSummary', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrPermissionRoot', 'Get-GPOZaurrPermissionSummary', 'Get-GPOZaurrSysvol', 'Get-GPOZaurrSysvolDFSR', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurrContent', 'Invoke-GPOZaurrPermission', 'Invoke-GPOZaurrSupport', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrFolders', 'Remove-GPOZaurrLegacyFiles', 'Remove-GPOZaurrOrphaned', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner')
FunctionsToExport = @('Add-GPOPermission', 'Add-GPOZaurrPermission', 'Backup-GPOZaurr', 'Clear-GPOZaurrSysvolDFSR', 'ConvertFrom-CSExtension', 'Find-CSExtension', 'Get-GPOZaurr', 'Get-GPOZaurrAD', 'Get-GPOZaurrBackupInformation', 'Get-GPOZaurrBroken', 'Get-GPOZaurrDictionary', 'Get-GPOZaurrDuplicateObject', 'Get-GPOZaurrFiles', 'Get-GPOZaurrFilesPolicyDefinition', 'Get-GPOZaurrFolders', 'Get-GPOZaurrInheritance', 'Get-GPOZaurrLegacyFiles', 'Get-GPOZaurrLink', 'Get-GPOZaurrLinkSummary', 'Get-GPOZaurrNetLogon', 'Get-GPOZaurrOwner', 'Get-GPOZaurrPassword', 'Get-GPOZaurrPermission', 'Get-GPOZaurrPermissionConsistency', 'Get-GPOZaurrPermissionRoot', 'Get-GPOZaurrPermissionSummary', 'Get-GPOZaurrSysvolDFSR', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurr', 'Invoke-GPOZaurrContent', 'Invoke-GPOZaurrPermission', 'Invoke-GPOZaurrSupport', 'New-GPOZaurrWMI', 'Remove-GPOPermission', 'Remove-GPOZaurr', 'Remove-GPOZaurrBroken', 'Remove-GPOZaurrDuplicateObject', 'Remove-GPOZaurrFolders', 'Remove-GPOZaurrLegacyFiles', 'Remove-GPOZaurrPermission', 'Remove-GPOZaurrWMI', 'Repair-GPOZaurrNetLogonOwner', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner')
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
ModuleVersion = '0.0.62'
ModuleVersion = '0.0.72'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
Tags = @('Windows', 'ActiveDirectory', 'GPO', 'GroupPolicy')
ProjectUri = 'https://github.com/EvotecIT/GPOZaurr'
ExternalModuleDependencies = @('CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility')
ExternalModuleDependencies = @('CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Security')
}
}
RequiredModules = @(@{
ModuleVersion = '0.0.181'
ModuleVersion = '0.0.186'
ModuleName = 'PSSharedGoods'
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
}, @{
ModuleVersion = '0.0.98'
ModuleVersion = '0.0.100'
ModuleName = 'ADEssentials'
Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
}, @{
ModuleVersion = '0.0.112'
ModuleVersion = '0.0.119'
ModuleName = 'PSWriteHTML'
Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
}, 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility')
}, 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Security')
RootModule = 'GPOZaurr.psm1'
}
+19
View File
@@ -0,0 +1,19 @@
function Export-GPOZaurr {
[cmdletBinding()]
param(
)
$Output = [ordered] @{}
foreach ($T in $Script:GPOConfiguration.Keys) {
if ($Script:GPOConfiguration[$T].Enabled -eq $true) {
$Output[$T] = [ordered]@{
Action = $Script:GPOConfiguration[$T].Action
Data = $Script:GPOConfiguration[$T].Data
Name = $Script:GPOConfiguration[$T].Name
Summary = $Script:GPOConfiguration[$T].Summary
Variables = $Script:GPOConfiguration[$T].Variables
}
}
}
$Output
}
-20
View File
@@ -1,20 +0,0 @@
function Invoke-GPOZaurr {
[cmdletBinding()]
param(
)
New-HTML {
New-HTMLTab -Name 'Permissions' {
New-HTMLTab -Name 'Root' {
}
New-HTMLTab -Name 'Edit & Modify' {
}
New-HTMLTab -Name 'Consistency' {
}
}
New-HTMLTab -Name ''
} -Online -ShowHTML
}
+25
View File
@@ -0,0 +1,25 @@
$GPOZaurrAnalysis = [ordered] @{
Name = 'Group Policy Content'
Enabled = $true
Action = $null
Data = $null
Execute = {
Invoke-GPOZaurrContent
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
foreach ($Key in $GPOZaurrAnalysis['Data'].Keys) {
New-HTMLTab -Name $Key {
New-HTMLTable -DataTable $GPOZaurrAnalysis['Data'][$Key] -Filtering -Title $Key
}
}
}
}
+161
View File
@@ -0,0 +1,161 @@
$GPOZaurrConsistency = [ordered] @{
Name = 'GPO Permissions Consistency'
Enabled = $true
Action = $null
Data = $null
Execute = { Get-GPOZaurrPermissionConsistency -Type All -VerifyInheritance }
Processing = {
foreach ($GPO in $GPOZaurrConsistency['Data']) {
if ($GPO.ACLConsistent -eq $true) {
$GPOZaurrConsistency['Variables']['Consistent']++
} else {
$GPOZaurrConsistency['Variables']['Inconsistent']++
}
if ($GPO.ACLConsistentInside -eq $true) {
$GPOZaurrConsistency['Variables']['ConsistentInside']++
} else {
$GPOZaurrConsistency['Variables']['InconsistentInside']++
}
}
if ($GPOZaurrConsistency['Variables']['Inconsistent'].Count -gt 0 -or $GPOZaurrConsistency['Variables']['InconsistentInside'].Count -gt 0 ) {
$GPOZaurrConsistency['Action'] = $true
} else {
$GPOZaurrConsistency['Action'] = $false
}
}
Variables = @{
Consistent = 0
Inconsistent = 0
ConsistentInside = 0
InconsistentInside = 0
}
Overview = {
New-HTMLPanel {
New-HTMLText -Text 'Following chart 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: ', $GPOZaurrConsistency['Variables']['Consistent'] -FontWeight normal, bold
New-HTMLListItem -Text 'Inherited permissions consistency: ', $GPOZaurrConsistency['Variables']['ConsistentInside'] -FontWeight normal, bold
New-HTMLListItem -Text 'Inconsistent top level permissions: ', $GPOZaurrConsistency['Variables']['Inconsistent'] -FontWeight normal, bold
New-HTMLListItem -Text "Inconsistent inherited permissions: ", $GPOZaurrConsistency['Variables']['InconsistentInside'] -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.'
New-HTMLChart {
New-ChartLegend -Names 'Bad', 'Good' -Color PaleGreen, Salmon
New-ChartBarOptions -Type barStacked
New-ChartLegend -Name 'Consistent', 'Inconsistent'
New-ChartBar -Name 'TopLevel' -Value $GPOZaurrConsistency['Variables']['Consistent'], $GPOZaurrConsistency['Variables']['Inconsistent']
New-ChartBar -Name 'Inherited' -Value $GPOZaurrConsistency['Variables']['ConsistentInside'], $GPOZaurrConsistency['Variables']['InconsistentInside']
} -Title 'Permissions Consistency' -TitleAlignment center
}
}
Summary = {
New-HTMLText -FontSize 10pt -TextBlock {
"When GPO is created it creates an entry in Active Directory (metadata) and SYSVOL (content). "
"Two different places meens two different sets of permissions. Group Policy module is making sure the data in both places is correct. "
"However, for different reasons it's not nessecary the case and often permissions go out of sync between AD and SYSVOL. "
"This test verifies consistency of policies between AD and SYSVOL in two ways. "
"It checks top level permissions for a GPO, and then checks if all files within said GPO are inheriting permissions or have different permissions in place. "
}
New-HTMLText -Text 'Following list 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: ', $GPOZaurrConsistency['Variables']['Consistent'] -FontWeight normal, bold
New-HTMLListItem -Text 'Inherited permissions consistency: ', $GPOZaurrConsistency['Variables']['ConsistentInside'] -FontWeight normal, bold
New-HTMLListItem -Text 'Inconsistent top level permissions: ', $GPOZaurrConsistency['Variables']['Inconsistent'] -FontWeight normal, bold
New-HTMLListItem -Text "Inconsistent inherited permissions: ", $GPOZaurrConsistency['Variables']['InconsistentInside'] -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
}
Solution = {
New-HTMLSection -Invisible {
New-HTMLPanel {
& $GPOZaurrConsistency['Summary']
}
New-HTMLPanel {
New-HTMLChart {
New-ChartLegend -Names 'Bad', 'Good' -Color PaleGreen, Salmon
New-ChartBarOptions -Type barStacked
New-ChartLegend -Name 'Consistent', 'Inconsistent'
New-ChartBar -Name 'TopLevel' -Value $GPOZaurrConsistency['Variables']['Consistent'], $GPOZaurrConsistency['Variables']['Inconsistent']
New-ChartBar -Name 'Inherited' -Value $GPOZaurrConsistency['Variables']['ConsistentInside'], $GPOZaurrConsistency['Variables']['InconsistentInside']
} -Title 'Permissions Consistency' -TitleAlignment center
}
}
New-HTMLSection -Name 'Group Policy Permissions Consistency' {
New-HTMLTable -DataTable $GPOZaurrConsistency['Data'] -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 {
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 fixing permissions inconsistencies. To generate new report please use:"
New-HTMLCodeBlock -Code {
Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrPermissionsInconsistentBefore.html -Verbose -Type GPOConsistency
}
New-HTMLText -Text {
"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-GPOZaurrPermissionConsistency
$GPOOutput | Format-Table # do your actions as desired
}
New-HTMLText -Text "It provides same data as you see in table above just doesn't prettify it for you."
}
New-HTMLWizardStep -Name 'Fix inconsistent permissions' {
New-HTMLText -Text "Following command when executed fixes inconsistent permissions."
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-HTMLText -Text "Make sure to fill in TargetDomain to match your Domain Admin permission account"
New-HTMLCodeBlock -Code {
Repair-GPOZaurrPermissionConsistency -IncludeDomains "TargetDomain" -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 {
Repair-GPOZaurrPermissionConsistency -LimitProcessing 2 -IncludeDomains "TargetDomain"
}
New-HTMLText -TextBlock {
"This command when executed repairs only first X inconsistent permissions. Use LimitProcessing parameter to prevent mass fixing 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 fixed, we can skip to next step step"
}
New-HTMLWizardStep -Name 'Fix inconsistent downlevel permissions' {
New-HTMLText -Text "Unfortunetly this step is manual until automation is developed. "
New-HTMLText -Text "If there are inconsistent permissions found inside GPO one has to fix them manually by going into SYSVOL and making sure inheritance is enabled, and that permissions are consistent across all files."
}
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\GPOZaurrPermissionsInconsistentAfter.html -Verbose -Type GPOConsistency
}
New-HTMLText -Text "If everything is health in the report you're done! Enjoy rest of the day!" -Color BlueDiamond
}
} -RemoveDoneStepOnNavigateBack -Theme arrows -ToolbarButtonPosition center
}
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
$GPOZaurrDuplicates = [ordered] @{
Name = 'Duplicate (CNF) Group Policies'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrDuplicateObject
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrDuplicates['Data'] -Filtering
}
}
+21
View File
@@ -0,0 +1,21 @@
$GPOZaurrFiles = [ordered] @{
Name = 'SYSVOL (NetLogon) Files List'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrFiles
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrFiles['Data'] -Filtering
}
}
+198
View File
@@ -0,0 +1,198 @@
$GPOZaurrList = [ordered] @{
Name = 'Group Policy Empty & Unlinked'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurr
}
Processing = {
foreach ($GPO in $GPOZaurrList['Data']) {
if ($GPO.Linked -eq $false -and $GPO.Empty -eq $true) {
# Not linked, Empty
$GPOZaurrList['Variables']['GPOEmptyAndUnlinked']++
$GPOZaurrList['Variables']['GPOEmptyOrUnlinked']++
$GPOZaurrList['Variables']['GPONotLinked']++
$GPOZaurrList['Variables']['GPOEmpty']++
} elseif ($GPO.Linked -eq $true -and $GPO.Empty -eq $true) {
# Linked, But EMPTY
$GPOZaurrList['Variables']['GPOLinkedButEmpty']++
$GPOZaurrList['Variables']['GPOEmptyOrUnlinked']++
$GPOZaurrList['Variables']['GPOEmpty']++
$GPOZaurrList['Variables']['GPOLinked']++
} elseif ($GPO.Linked -eq $false) {
# Not linked, but not EMPTY
$GPOZaurrList['Variables']['GPONotLinked']++
$GPOZaurrList['Variables']['GPOEmptyOrUnlinked']++
$GPOZaurrList['Variables']['GPONotEmpty']++
} elseif ($GPO.Empty -eq $true) {
# Linked, But EMPTY
$GPOZaurrList['Variables']['GPOEmpty']++
$GPOZaurrList['Variables']['GPOEmptyOrUnlinked']++
$GPOZaurrList['Variables']['GPOLinked']++
} else {
# Linked, not EMPTY
$GPOZaurrList['Variables']['GPOValid']++
$GPOZaurrList['Variables']['GPOLinked']++
$GPOZaurrList['Variables']['GPONotEmpty']++
}
if ($GPO.LinksDisabledCount -eq $GPO.LinksCount -and $GPO.LinksCount -gt 0) {
$GPOZaurrList['Variables']['GPOLinkedButLinkDisabled']++
}
}
$GPOZaurrList['Variables']['GPOTotal'] = $GPOZaurrList['Data'].Count
}
Variables = [ordered] @{
GPONotLinked = 0
GPOLinked = 0
GPOEmpty = 0
GPONotEmpty = 0
GPOEmptyAndUnlinked = 0
GPOEmptyOrUnlinked = 0
GPOLinkedButEmpty = 0
GPOValid = 0
GPOLinkedButLinkDisabled = 0
GPOTotal = 0
}
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: ', $GPOZaurrList['Variables']['GPOTotal'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies valid: ", $GPOZaurrList['Variables']['GPOValid'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies to delete: ", $GPOZaurrList['Variables']['GPOEmptyOrUnlinked'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPOZaurrList['Variables']['GPONotLinked'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOZaurrList['Variables']['GPOEmpty'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOZaurrList['Variables']['GPOLinkedButEmpty'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOZaurrList['Variables']['GPOLinkedButLinkDisabled'] -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 $GPOZaurrList['Variables']['GPONotLinked'], $GPOZaurrList['Variables']['GPOLinked'], $GPOZaurrList['Variables']['GPOEmpty'], $GPOZaurrList['Variables']['GPOTotal']
New-ChartBar -Name 'Linked' -Value $GPOZaurrList['Variables']['GPOLinked'], $GPOZaurrList['Variables']['GPONotLinked']
New-ChartBar -Name 'Empty' -Value $GPOZaurrList['Variables']['GPONotEmpty'], $GPOZaurrList['Variables']['GPOEmpty']
New-ChartBar -Name 'Valid' -Value $GPOZaurrList['Variables']['GPOValid'], $GPOZaurrList['Variables']['GPOEmptyOrUnlinked']
} -TitleAlignment center
}
}
Solution = {
New-HTMLSection -Invisible {
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: ', $GPOZaurrList['Variables']['GPOTotal'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies valid: ", $GPOZaurrList['Variables']['GPOValid'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies to delete: ", $GPOZaurrList['Variables']['GPOEmptyOrUnlinked'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Group Policies that are unlinked (are not doing anything currently): ', $GPOZaurrList['Variables']['GPONotLinked'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are empty (have no settings): ", $GPOZaurrList['Variables']['GPOEmpty'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are linked, but empty: ", $GPOZaurrList['Variables']['GPOLinkedButEmpty'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies that are linked, but link disabled: ", $GPOZaurrList['Variables']['GPOLinkedButLinkDisabled'] -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-HTMLPanel {
New-HTMLChart -Title 'Group Policies Empty & Unlinked' {
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 $GPOZaurrList['Variables']['GPONotLinked'], $GPOZaurrList['Variables']['GPOLinked'], $GPOZaurrList['Variables']['GPOEmpty'], $GPOZaurrList['Variables']['GPOTotal']
New-ChartBar -Name 'Linked' -Value $GPOZaurrList['Variables']['GPOLinked'], $GPOZaurrList['Variables']['GPONotLinked']
New-ChartBar -Name 'Empty' -Value $GPOZaurrList['Variables']['GPONotEmpty'], $GPOZaurrList['Variables']['GPOEmpty']
New-ChartBar -Name 'Valid' -Value $GPOZaurrList['Variables']['GPOValid'], $GPOZaurrList['Variables']['GPOEmptyOrUnlinked']
} -TitleAlignment center
}
}
New-HTMLSection -Name 'Group Policies List' {
New-HTMLTable -DataTable $GPOZaurrList['Data'] -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
}
}
}
}
}
@@ -0,0 +1,174 @@
$GPOZaurrNetLogonPermissions = [ordered] @{
Name = 'NetLogon Permissions'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrNetLogon
}
Processing = {
foreach ($File in $GPOZaurrNetLogonPermissions['Data']) {
if ($File.FileSystemRights -eq 'Owner') {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwners']++
if ($File.PrincipalType -eq 'WellKnownAdministrative') {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrative']++
} elseif ($File.PrincipalType -eq 'Administrative') {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrative']++
} else {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersNotAdministrative']++
}
if ($File.PrincipalSid -eq 'S-1-5-32-544') {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrators']++
} elseif ($File.PrincipalType -in 'WellKnownAdministrative', 'Administrative') {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrativeNotAdministrators']++
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix']++
} else {
$GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix']++
}
$GPOZaurrNetLogonPermissions['Variables']['Owner'].Add($File)
} else {
$GPOZaurrNetLogonPermissions['Variables']['NonOwner'].Add($File)
}
}
if ($GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix'].Count -gt 0) {
$GPOZaurrNetLogonPermissions['Action'] = $true
} else {
$GPOZaurrNetLogonPermissions['Action'] = $false
}
}
Variables = @{
NetLogonOwners = 0
NetLogonOwnersAdministrators = 0
NetLogonOwnersNotAdministrative = 0
NetLogonOwnersAdministrative = 0
NetLogonOwnersAdministrativeNotAdministrators = 0
NetLogonOwnersToFix = 0
Owner = [System.Collections.Generic.List[PSCustomObject]]::new()
NonOwner = [System.Collections.Generic.List[PSCustomObject]]::new()
}
Overview = {
New-HTMLPanel {
New-HTMLText -Text 'Following chart presents ', 'NetLogon Summary' -FontSize 10pt -FontWeight normal, bold
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'NetLogon Files in Total: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwners'] -FontWeight normal, bold
New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text "NetLogon Owners requiring change: ", $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Not Administrative: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrativeNotAdministrators'] -FontWeight normal, bold
}
}
} -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 $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
New-ChartPie -Name 'Incorrect Owners' -Value $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix'] -Color Crimson
} -Title 'NetLogon Owners' -TitleAlignment center
}
New-HTMLPanel {
}
}
Solution = {
New-HTMLTab -Name 'NetLogon Owners' {
New-HTMLSection -Invisible {
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 {
New-HTMLListItem -Text 'NetLogon Files in Total: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwners'] -FontWeight normal, bold
New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text "NetLogon Owners requiring change: ", $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Not Administrative: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrativeNotAdministrators'] -FontWeight normal, bold
}
}
} -FontSize 10pt
New-HTMLText -Text "Follow the steps below table to get NetLogon Owners into compliant state." -FontSize 10pt
}
New-HTMLPanel {
New-HTMLChart {
New-ChartPie -Name 'Correct Owners' -Value $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
New-ChartPie -Name 'Incorrect Owners' -Value $GPOZaurrNetLogonPermissions['Variables']['NetLogonOwnersToFix'] -Color Crimson
} -Title 'NetLogon Owners' -TitleAlignment center
}
}
New-HTMLSection -Name 'NetLogon Files List' {
New-HTMLTable -DataTable $GPOZaurrNetLogonPermissions['Variables']['Owner'] -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 {
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\GPOZaurrNetLogonBefore.html -Verbose -Type NetLogon
}
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 {
$NetLogonOutput = Get-GPOZaurrNetLogon -Verbose
$NetLogonOutput | 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 'Set non-compliant file owners to BUILTIN\Administrators' {
New-HTMLText -Text "Following command when executed runs internally command that lists all file owners and if it doesn't match changes it BUILTIN\Administrators. It doesn't change compliant owners."
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 {
Repair-GPOZaurrNetLogonOwner -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 changed matches expected data. Once happy with results please follow with command: "
}
New-HTMLCodeBlock -Code {
Repair-GPOZaurrNetLogonOwner -Verbose -LimitProcessing 2
}
New-HTMLText -TextBlock {
"This command when executed sets new owner only on first X non-compliant NetLogon files. Use LimitProcessing parameter to prevent mass change 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-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\GPOZaurrNetLogonAfter.html -Verbose -Type NetLogon
}
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
}
}
}
}
New-HTMLTab -Name 'NetLogon Permissions' {
New-HTMLSection -Name 'NetLogon Files List' {
New-HTMLTable -DataTable $GPOZaurrNetLogonPermissions['Variables']['NonOwner'] -Filtering
}
}
}
}
+178
View File
@@ -0,0 +1,178 @@
$GPOZaurrOrphans = [ordered] @{
Name = 'Orphaned Group Policies'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrBroken
}
Processing = {
#$NotAvailableInAD = [System.Collections.Generic.List[PSCustomObject]]::new()
#$NotAvailableOnSysvol = [System.Collections.Generic.List[PSCustomObject]]::new()
#$NotAvailablePermissionIssue = [System.Collections.Generic.List[PSCustomObject]]::new()
foreach ($GPO in $GPOZaurrOrphans['Data']) {
if ($GPO.Status -eq 'Not available in AD') {
#$NotAvailableInAD.Add($NotAvailableInAD)
$GPOZaurrOrphans['Variables']['NotAvailableInAD']++
} elseif ($GPO.Status -eq 'Not available on SYSVOL') {
#$NotAvailableOnSysvol.Add($NotAvailableInAD)
$GPOZaurrOrphans['Variables']['NotAvailableOnSysvol']++
} elseif ($GPO.Status -eq 'Permissions issue') {
#$NotAvailablePermissionIssue.Add($NotAvailableInAD)
$GPOZaurrOrphans['Variables']['NotAvailablePermissionIssue']++
}
}
}
Variables = @{
NotAvailableInAD = 0
NotAvailableOnSysvol = 0
NotAvailablePermissionIssue = 0
}
Overview = {
New-HTMLPanel {
New-HTMLText -TextBlock {
"Group Policies are stored in two places - Active Directory (metadata) and SYSVOL (content)."
"Since those are managed in different ways, replicated in different ways it's possible because of different issues they get out of sync."
}
New-HTMLText -Text "For example:"
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'USN Rollback in AD could cause group policies to reappar in Active Directory, yet SYSVOL data would be unavailable'
New-HTMLListItem -Text 'Group Policy deletion failing to delete GPO content'
New-HTMLListItem -Text 'DFSR replication failing between DCs'
}
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: ', $GPOZaurrOrphans['Variables']['NotAvailableInAD'] -FontWeight normal, bold
New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $GPOZaurrOrphans['Variables']['NotAvailableOnSysvol'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $GPOZaurrOrphans['Variables']['NotAvailablePermissionIssue'] -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 $GPOZaurrOrphans['Variables']['NotAvailableInAD'], $GPOZaurrOrphans['Variables']['NotAvailableOnSysvol'], $GPOZaurrOrphans['Variables']['NotAvailablePermissionIssue']
} -Title 'Broken / Orphaned Group Policies' -TitleAlignment center
}
}
Summary = {
New-HTMLPanel {
New-HTMLText -TextBlock {
"Group Policies are stored in two places - Active Directory (metadata) and SYSVOL (content)."
"Since those are managed in different ways, replicated in different ways it's possible because of different issues they get out of sync."
} -FontSize 10pt
New-HTMLText -Text "For example:" -FontSize 10pt -FontWeight bold
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'USN Rollback in AD could cause already deleted Group Policies to reapper in Active Directory, yet SYSVOL data would be unavailable'
New-HTMLListItem -Text 'Group Policy deletion failing to delete GPO content'
New-HTMLListItem -Text 'Permission issue preventing deletion of GPO content'
New-HTMLListItem -Text 'Failing DFSR replication between DCs'
} -FontSize 10pt
New-HTMLText -Text 'Following problems were detected:' -FontSize 10pt -FontWeight bold
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Group Policies on SYSVOL, but no details in AD: ', $GPOZaurrOrphans['Variables']['NotAvailableInAD'] -FontWeight normal, bold
New-HTMLListItem -Text 'Group Policies in AD, but no content on SYSVOL: ', $GPOZaurrOrphans['Variables']['NotAvailableOnSysvol'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies which couldn't be assed due to permissions issue: ", $GPOZaurrOrphans['Variables']['NotAvailablePermissionIssue'] -FontWeight normal, bold
} -FontSize 10pt
New-HTMLText -Text "Please review output in table and follow the steps below table to get Active Directory Group Policies in healthy state." -FontSize 10pt
}
}
Solution = {
New-HTMLSection -Invisible {
& $GPOZaurrOrphans['Summary']
New-HTMLPanel {
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 $GPOZaurrOrphans['Variables']['NotAvailableInAD'], $GPOZaurrOrphans['Variables']['NotAvailableOnSysvol'], $GPOZaurrOrphans['Variables']['NotAvailablePermissionIssue']
} -Title 'Broken / Orphaned Group Policies' -TitleAlignment center
}
}
New-HTMLSection -Name 'Health State of Group Policies' {
New-HTMLTable -DataTable $GPOZaurrOrphans['Data'] -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
}
}
}
}
}
+163
View File
@@ -0,0 +1,163 @@
$GPOZaurrOwners = [ordered] @{
Name = 'Group Policy Owners'
Enabled = $true
Action = $null
Data = $null
Execute = { Get-GPOZaurrOwner -IncludeSysvol }
Processing = {
foreach ($GPO in $GpoZaurrOwners['Data']) {
if ($GPO.IsOwnerConsistent) {
$GpoZaurrOwners['Variables']['IsConsistent']++
} else {
$GpoZaurrOwners['Variables']['IsNotConsistent']++
}
if ($GPO.IsOwnerAdministrative) {
$GpoZaurrOwners['Variables']['IsAdministrative']++
} else {
$GpoZaurrOwners['Variables']['IsNotAdministrative']++
}
if (($GPO.IsOwnerAdministrative -eq $false -or $GPO.IsOwnerConsistent -eq $false) -and $GPO.SysvolExists -eq $true) {
$GpoZaurrOwners['Variables']['WillFix']++
} elseif ($GPO.SysvolExists -eq $false) {
$GpoZaurrOwners['Variables']['RequiresDiffFix']++
} else {
$GpoZaurrOwners['Variables']['WillNotTouch']++
}
}
}
Variables = [ordered] @{
IsAdministrative = 0
IsNotAdministrative = 0
IsConsistent = 0
IsNotConsistent = 0
WillFix = 0
RequiresDiffFix = 0
WillNotTouch = 0
}
Overview = {
New-HTMLPanel {
New-HTMLText -Text 'Following chart presents Group Policy owners and whether they are administrative and consistent. By design an owner of Group Policy should be Domain Admins or Enterprise Admins group only to prevent malicious takeover. ', `
"It's also important that owner in Active Directory matches owner on SYSVOL (file system)." -FontSize 10pt
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Administrative Owners: ', $GpoZaurrOwners['Variables']['IsAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Non-Administrative Owners: ', $GpoZaurrOwners['Variables']['IsNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text "Owners consistent in AD and SYSVOL: ", $GpoZaurrOwners['Variables']['IsConsistent'] -FontWeight normal, bold
New-HTMLListItem -Text "Owners not-consistent in AD and SYSVOL: ", $GpoZaurrOwners['Variables']['IsNotConsistent'] -FontWeight normal, bold
} -FontSize 10pt
New-HTMLChart {
New-ChartBarOptions -Type barStacked
New-ChartLegend -Name 'Yes', 'No' -Color PaleGreen, Orchid
New-ChartBar -Name 'Is administrative' -Value $GpoZaurrOwners['Variables']['IsAdministrative'], $GpoZaurrOwners['Variables']['IsNotAdministrative']
New-ChartBar -Name 'Is consistent' -Value $GpoZaurrOwners['Variables']['IsConsistent'], $GpoZaurrOwners['Variables']['IsNotConsistent']
} -Title 'Group Policy Owners' -TitleAlignment center
}
}
Summary = {
New-HTMLText -FontSize 10pt -TextBlock {
"By default GPO creation is usually maintained by Domain Admins or Enterprise Admins. "
"When GPO is created by member of Domain Admins or Enterprise Admins group the GPO Owner is set to Domain Admins. "
"When GPO is created by member of Group Policy Creator Owners or other group has delegated rights to create a GPO the owner of said GPO is not Domain Admins group but is assigned to relevant user. "
"GPO Owners should be Domain Admins or Enterprise Admins to prevent abuse. If that isn't so it means owner is able to fully control GPO and potentially change it's settings in uncontrolled way. "
"While at the moment of creation of new GPO it's not a problem, in long term it's possible such person may no longer be admin, yet keep their rights over GPO. "
}
New-HTMLText -FontSize 10pt -TextBlock {
"As you're aware Group Policies are stored in 2 places. In Active Directory (metadata) and SYSVOL (settings). This means that there are 2 places where GPO Owners exists. "
"This also means that for multiple reasons AD and SYSVOL can be out of sync when it comes to their permissions which can lead to uncontrolled ability to modify them. "
"Ownership in Active Directory and Ownership of SYSVOL for said GPO are required to be the same. "
}
New-HTMLText -Text "Here's a short summary of ", "Group Policy Owners", ": " -FontSize 10pt -FontWeight normal, bold, normal
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Administrative Owners: ', $GpoZaurrOwners['Variables']['IsAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Non-Administrative Owners: ', $GpoZaurrOwners['Variables']['IsNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text "Owners consistent in AD and SYSVOL: ", $GpoZaurrOwners['Variables']['IsConsistent'] -FontWeight normal, bold
New-HTMLListItem -Text "Owners not-consistent in AD and SYSVOL: ", $GpoZaurrOwners['Variables']['IsNotConsistent'] -FontWeight normal, bold
} -FontSize 10pt
New-HTMLText -FontSize 10pt -Text "This gives us: "
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Group Policies requiring owner change: ', $GpoZaurrOwners['Variables']['WillFix'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies which can't be fixed (no SYSVOL?): ", $GpoZaurrOwners['Variables']['RequiresDiffFix'] -FontWeight normal, bold
New-HTMLListItem -Text "Group Policies unaffected: ", $GpoZaurrOwners['Variables']['WillNotTouch'] -FontWeight normal, bold
} -FontSize 10pt
}
Solution = {
New-HTMLSection -Invisible {
New-HTMLPanel {
& $GpoZaurrOwners['Summary']
}
New-HTMLPanel {
New-HTMLChart {
New-ChartBarOptions -Type barStacked
New-ChartLegend -Name 'Yes', 'No' -Color LightGreen, Salmon
New-ChartBar -Name 'Is administrative' -Value $GpoZaurrOwners['Variables']['IsAdministrative'], $GpoZaurrOwners['Variables']['IsNotAdministrative']
New-ChartBar -Name 'Is consistent' -Value $GpoZaurrOwners['Variables']['IsConsistent'], $GpoZaurrOwners['Variables']['IsNotConsistent']
} -Title 'Group Policy Owners' -TitleAlignment center
}
}
New-HTMLSection -Name 'Group Policy Owners' {
New-HTMLTable -DataTable $GpoZaurrOwners['Data'] -Filtering {
New-HTMLTableCondition -Name 'IsOwnerConsistent' -Value $false -BackgroundColor Salmon -ComparisonType string -Row
New-HTMLTableCondition -Name 'IsOwnerAdministrative' -Value $false -BackgroundColor Salmon -ComparisonType string -Row
} -PagingOptions 10, 20, 30, 40, 50
}
New-HTMLSection -Name 'Steps to fix Group Policy Owners' {
New-HTMLContainer {
New-HTMLSpanStyle -FontSize 10pt {
New-HTMLText -Text 'Following steps will guide you how to fix group policy owners'
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 fixing Group Policy Owners. To generate new report please use:"
New-HTMLCodeBlock -Code {
Invoke-GPOZaurr -FilePath $Env:UserProfile\Desktop\GPOZaurrGPOOwnersBefore.html -Verbose -Type GPOOwners
}
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 {
$OwnersGPO = Get-GPOZaurrOwner -IncludeSysvol -Verbose
$OwnersGPO | 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 'Set GPO Owners to Administrative (Domain Admins)' {
New-HTMLText -Text "Following command will find any GPO which doesn't have proper GPO Owner (be it due to inconsistency or not being Domain Admin) and will enforce new GPO Owner. "
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 {
Set-GPOZaurrOwner -Type All -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 changed matches expected data. Once happy with results please follow with command: "
}
New-HTMLCodeBlock -Code {
Set-GPOZaurrOwner -Type All -Verbose -LimitProcessing 2
}
New-HTMLText -TextBlock {
"This command when executed sets new owner only on first X non-compliant GPO Owners for AD/SYSVOL. Use LimitProcessing parameter to prevent mass change 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-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\GPOZaurrGPOOwnersAfter.html -Verbose -Type GPOOwners
}
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
}
}
}
}
}
+21
View File
@@ -0,0 +1,21 @@
$GPOZaurrPassword = [ordered] @{
Name = 'Group Policy Passwords'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPassword
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrPassword['Data'] -Filtering
}
}
+21
View File
@@ -0,0 +1,21 @@
$GPOZaurrPermissions = [ordered] @{
Name = 'Group Policy Permissions'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPermission -Type All -IncludePermissionType GpoEditDeleteModifySecurity, GpoEdit, GpoCustom #-IncludeOwner
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrPermissions['Data'] -Filtering
}
}
@@ -0,0 +1,21 @@
$GPOZaurrPermissionsRoot = [ordered] @{
Name = 'Group Policies Root Permissions'
Enabled = $true
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPermissionRoot -SkipNames
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrPermissionsRoot['Data'] -Filtering
}
}
@@ -0,0 +1,21 @@
$GPOZaurrSysVolLegacyFiles = [ordered] @{
Name = 'SYSVOL Legacy ADM Files'
Enabled = $false
Action = $null
Data = $null
Execute = {
Get-GPOZaurrLegacyFiles
}
Processing = {
}
Variables = @{
}
Overview = {
}
Solution = {
New-HTMLTable -DataTable $GPOZaurrSysVolLegacyFiles['Data'] -Filtering
}
}
+1
View File
@@ -1,4 +1,5 @@
function New-GPOZaurrReportConsole {
[cmdletBinding()]
param(
[System.Collections.IDictionary] $Results
)
+19
View File
@@ -0,0 +1,19 @@
function Reset-GPOZaurrStatus {
param(
)
if (-not $Script:DefaultTypes) {
$Script:DefaultTypes = foreach ($T in $Script:GPOConfiguration.Keys) {
if ($Script:GPOConfiguration[$T].Enabled) {
$T
}
}
} else {
foreach ($T in $Script:GPOConfiguration.Keys) {
$Script:GPOConfiguration[$T]['Enabled'] = $false
}
foreach ($T in $Script:DefaultTypes) {
$Script:GPOConfiguration[$T]['Enabled'] = $true
}
}
}
+14
View File
@@ -0,0 +1,14 @@
$Script:GPOConfiguration = [ordered] @{
GPOOrphans = $GPOZaurrOrphans
GPOOwners = $GPOZaurrOwners
GPOConsistency = $GPOZaurrConsistency
GPODuplicates = $GPOZaurrDuplicates
GPOList = $GPOZaurrList
GPOPassword = $GPOZaurrPassword
GPOPermissions = $GPOZaurrPermissions
GPOPermissionsRoot = $GPOZaurrPermissionsRoot
GPOFiles = $GPOZaurrFiles
GPOAnalysis = $GPOZaurrAnalysis
NetLogonPermissions = $GPOZaurrNetLogonPermissions
SysVolLegacyFiles = $GPOZaurrSysVolLegacyFiles
}
+38 -36
View File
@@ -5,14 +5,15 @@
[string] $Server,
[string] $Domain,
[System.Collections.IDictionary] $PoliciesAD,
$PoliciesSearchBase
[string] $PoliciesSearchBase
)
$Differences = @{ }
$SysvolHash = @{ }
$GPOGUIDS = $GPOs.ID.GUID
$SysVolPath = "\\$($Server)\SYSVOL\$Domain\Policies"
try {
$SYSVOL = Get-ChildItem -Path "\\$($Server)\SYSVOL\$Domain\Policies" -ErrorAction Stop
$SYSVOL = Get-ChildItem -Path "\\$($Server)\SYSVOL\$Domain\Policies" -Exclude 'PolicyDefinitions' -ErrorAction Stop -Verbose:$false
} catch {
$Sysvol = $Null
}
@@ -49,17 +50,20 @@
if ($null -ne $SysvolHash[$GPO.Id.GUID].FullName) {
$FullPath = $SysvolHash[$GPO.Id.GUID].FullName
try {
$ACL = Get-Acl -Path $SysvolHash[$GPO.Id.GUID].FullName -ErrorAction Stop
$ACL = Get-Acl -Path $SysvolHash[$GPO.Id.GUID].FullName -ErrorAction Stop -Verbose:$false
$Owner = $ACL.Owner
$ErrorMessage = ''
} catch {
Write-Warning "Get-GPOZaurrSysvol - ACL reading (1) failed for $FullPath with error: $($_.Exception.Message)"
Write-Warning "Get-GPOZaurrBroken - ACL reading (1) failed for $FullPath with error: $($_.Exception.Message)"
$ACL = $null
$Owner = ''
$ErrorMessage = $_.Exception.Message
}
} else {
$FullPath = -join ($SysVolPath, "\{$($GPO.Id.Guid)}")
$ACL = $null
$Owner = ''
$ErrorMessage = 'Not found on SYSVOL'
}
if ($null -eq $Differences[$GPO.Id.Guid]) {
$SysVolStatus = 'Unknown Issue'
@@ -90,39 +94,37 @@
# Now we need to list thru Sysvol files and fine those that do not exists as GPO and create dummy GPO objects to show orphaned gpos
foreach ($_ in $Differences.Keys) {
if ($Differences[$_] -in 'Not available in AD', 'Permissions issue') {
if ($SysvolHash[$_].BaseName -notcontains 'PolicyDefinitions') {
$FullPath = $SysvolHash[$_].FullName
try {
$ACL = Get-Acl -Path $FullPath -ErrorAction Stop
$Owner = $ACL.Owner
$ErrorMessage = ''
} catch {
Write-Warning "Get-GPOZaurrSysvol - ACL reading (2) failed for $FullPath with error: $($_.Exception.Message)"
$ACL = $null
$Owner = $null
$ErrorMessage = $_.Exception.Message
}
$FullPath = $SysvolHash[$_].FullName
try {
$ACL = Get-Acl -Path $FullPath -ErrorAction Stop
$Owner = $ACL.Owner
$ErrorMessage = ''
} catch {
Write-Warning "Get-GPOZaurrBroken - ACL reading (2) failed for $FullPath with error: $($_.Exception.Message)"
$ACL = $null
$Owner = $null
$ErrorMessage = $_.Exception.Message
}
[PSCustomObject] @{
DisplayName = $SysvolHash[$_].BaseName
Status = $Differences[$_]
DomainName = $Domain
SysvolServer = $Server
SysvolStatus = 'Exists' #$Differences[$GPO.Id.Guid]
GpoStatus = $Differences[$_]
Owner = ''
FileOwner = $Owner
Id = $_
Path = $FullPath
DistinguishedName = -join ("CN={", $_, "},", $PoliciesSearchBase)
Description = $null
CreationTime = $SysvolHash[$_].CreationTime
ModificationTime = $SysvolHash[$_].LastWriteTime
UserVersion = $null
ComputerVersion = $null
WmiFilter = $null
Error = $ErrorMessage
}
[PSCustomObject] @{
DisplayName = $SysvolHash[$_].BaseName
Status = $Differences[$_]
DomainName = $Domain
SysvolServer = $Server
SysvolStatus = 'Exists' #$Differences[$GPO.Id.Guid]
GpoStatus = $Differences[$_]
Owner = ''
FileOwner = $Owner
Id = $_
Path = $FullPath
DistinguishedName = -join ("CN={", $_, "},", $PoliciesSearchBase)
Description = $null
CreationTime = $SysvolHash[$_].CreationTime
ModificationTime = $SysvolHash[$_].LastWriteTime
UserVersion = $null
ComputerVersion = $null
WmiFilter = $null
Error = $ErrorMessage
}
}
}
+18 -6
View File
@@ -29,9 +29,13 @@
if (-not $GPOPath) {
foreach ($Domain in $ForestInformation.Domains) {
$QueryServer = $ForestInformation.QueryServers[$Domain]['HostName'][0]
$Count = 0
if ($GPOName) {
Get-GPO -Name $GPOName -Domain $Domain -Server $QueryServer -ErrorAction SilentlyContinue | ForEach-Object {
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
$GroupPolicies = Get-GPO -Name $GPOName -Domain $Domain -Server $QueryServer -ErrorAction SilentlyContinue
$GroupPolicies | ForEach-Object {
$Count++
#Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
Write-Verbose "Get-GPOZaurr - Processing [$($_.DomainName)]($Count/$($GroupPolicies.Count)) $($_.DisplayName)"
if (-not $Limited) {
try {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain -ErrorAction Stop
@@ -45,8 +49,11 @@
}
}
} elseif ($GPOGuid) {
Get-GPO -Guid $GPOGuid -Domain $Domain -Server $QueryServer -ErrorAction SilentlyContinue | ForEach-Object {
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
$GroupPolicies = Get-GPO -Guid $GPOGuid -Domain $Domain -Server $QueryServer -ErrorAction SilentlyContinue
$GroupPolicies | ForEach-Object {
$Count++
#Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
Write-Verbose "Get-GPOZaurr - Processing [$($_.DomainName)]($Count/$($GroupPolicies.Count)) $($_.DisplayName)"
if (-not $Limited) {
try {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain -ErrorAction Stop
@@ -60,8 +67,11 @@
}
}
} else {
Get-GPO -All -Server $QueryServer -Domain $Domain -ErrorAction SilentlyContinue | ForEach-Object {
Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
$GroupPolicies = Get-GPO -All -Server $QueryServer -Domain $Domain -ErrorAction SilentlyContinue
$GroupPolicies | ForEach-Object {
$Count++
#Write-Verbose "Get-GPOZaurr - Getting GPO $($_.DisplayName) / ID: $($_.ID) from $Domain"
Write-Verbose "Get-GPOZaurr - Processing [$($_.DomainName)]($Count/$($GroupPolicies.Count)) $($_.DisplayName)"
if (-not $Limited) {
try {
$XMLContent = Get-GPOReport -ID $_.ID -ReportType XML -Server $ForestInformation.QueryServers[$Domain].HostName[0] -Domain $Domain -ErrorAction Stop
@@ -78,11 +88,13 @@
}
} else {
foreach ($Path in $GPOPath) {
Write-Verbose "Get-GPOZaurr - Getting GPO content from XML files"
Get-ChildItem -LiteralPath $Path -Recurse -Filter *.xml | ForEach-Object {
$XMLContent = [XML]::new()
$XMLContent.Load($_.FullName)
Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -PermissionsOnly:$PermissionsOnly.IsPresent
}
Write-Verbose "Get-GPOZaurr - Finished GPO content from XML files"
}
}
}
@@ -1,4 +1,5 @@
function Get-GPOZaurrSysvol {
function Get-GPOZaurrBroken {
[alias('Get-GPOZaurrSysvol')]
[cmdletBinding()]
param(
[alias('ForestName')][string] $Forest,
@@ -13,7 +14,8 @@
)
$ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExcludeDomainControllers $ExcludeDomainControllers -IncludeDomainControllers $IncludeDomainControllers -SkipRODC:$SkipRODC -ExtendedForestInformation $ExtendedForestInformation -Extended
foreach ($Domain in $ForestInformation.Domains) {
Write-Verbose "Get-WinADGPOSysvolFolders - Processing $Domain"
$TimeLog = Start-TimeLog
Write-Verbose "Get-GPOZaurrBroken - Starting process for $Domain"
$QueryServer = $ForestInformation['QueryServers']["$Domain"].HostName[0]
$SystemsContainer = $ForestInformation['DomainsExtended'][$Domain].SystemsContainer
$PoliciesAD = @{}
@@ -34,7 +36,7 @@
Try {
[Array]$GPOs = Get-GPO -All -Domain $Domain -Server $QueryServer
} catch {
Write-Warning "Get-GPOZaurrSysvol - Couldn't get GPOs from $Domain. Error: $($_.Exception.Message)"
Write-Warning "Get-GPOZaurrBroken - Couldn't get GPOs from $Domain. Error: $($_.Exception.Message)"
continue
}
if ($GPOs.Count -ge 2) {
@@ -42,12 +44,14 @@
Test-SysVolFolders -GPOs $GPOs -Server $Domain -Domain $Domain -PoliciesAD $PoliciesAD -PoliciesSearchBase $PoliciesSearchBase
} else {
foreach ($Server in $ForestInformation['DomainDomainControllers']["$Domain"]) {
Write-Verbose "Get-GPOZaurrSysvol - Processing $Domain \ $($Server.HostName.Trim())"
Write-Verbose "Get-GPOZaurrBroken - Processing $Domain \ $($Server.HostName.Trim())"
Test-SysVolFolders -GPOs $GPOs -Server $Server.Hostname -Domain $Domain -PoliciesAD $PoliciesAD -PoliciesSearchBase $PoliciesSearchBase
}
}
} else {
Write-Warning "Get-GPOZaurrSysvol - GPO count for $Domain is less then 2. This is not expected for fully functioning domain. Skipping processing SYSVOL folder."
Write-Warning "Get-GPOZaurrBroken - GPO count for $Domain is less then 2. This is not expected for fully functioning domain. Skipping processing SYSVOL folder."
}
$TimeEnd = Stop-TimeLog -Time $TimeLog -Option OneLiner
Write-Verbose "Get-GPOZaurrBroken - Finishing process for $Domain (Time to process: $TimeEnd)"
}
}
+21
View File
@@ -0,0 +1,21 @@
function Get-GPOZaurrDuplicateObject {
[cmdletBinding()]
param(
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation
)
$getWinADDuplicateObjectSplat = @{
Forest = $Forest
IncludeDomains = $IncludeDomains
ExcludeDomains = $ExcludeDomains
ExtendedForestInformation = $ExtendedForestInformation
PartialMatchDistinguishedName = "*,CN=Policies,CN=System,DC=*"
Extended = $true
}
$DuplicateObjects = Get-WinADDuplicateObject @getWinADDuplicateObjectSplat
$DuplicateObjects
}
+1 -1
View File
@@ -20,7 +20,7 @@
}
}
foreach ($e in $err) {
Write-Warning "Get-GPOZaurrLegacy - $($e.Exception.Message) ($($e.CategoryInfo.Reason))"
Write-Warning "Get-GPOZaurrLegacyFiles - $($e.Exception.Message) ($($e.CategoryInfo.Reason))"
}
}
}
+79
View File
@@ -0,0 +1,79 @@
function Get-GPOZaurrNetLogon {
[cmdletBinding(DefaultParameterSetName = 'Default')]
param(
[parameter(ParameterSetName = 'OwnerOnly')][switch] $OwnerOnly,
[parameter(ParameterSetName = 'SkipOwner')][switch] $SkipOwner,
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation
)
$ForestInformation = Get-WinADForestDetails -Extended -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
$FilesAll = foreach ($Domain in $ForestInformation.Domains) {
$Path = -join ("\\", $Domain, '\Netlogon')
$PathOnSysvol = -join ("\\", $Domain, "\SYSVOL\", $Domain, "\Scripts")
$Files = Get-ChildItem -LiteralPath $Path -Recurse -Force
foreach ($_ in $Files) {
$ACL = Get-Acl -Path $_.FullName
if ($ACL.Owner) {
$IdentityOwner = Convert-Identity -Identity $ACL.Owner -Verbose:$false
} else {
$IdentityOwner = [PSCustomObject] @{ SID = ''; Type = 'Uknown' }
}
if (-not $OwnerOnly) {
if (-not $SkipOwner) {
[PSCustomObject] @{
FullName = $_.FullName
Extension = $_.Extension
CreationTime = $_.CreationTime
LastAccessTime = $_.LastAccessTime
LastWriteTime = $_.LastWriteTime
Attributes = $_.Attributes
AccessControlType = 'Allow' # : Allow
Principal = $IdentityOwner.Name # : BUILTIN\Administrators
PrincipalSid = $IdentityOwner.SID
PrincipalType = $IdentityOwner.Type
FileSystemRights = 'Owner' # : FullControl
IsInherited = $false
FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol)
#Owner = $ACL.Owner
}
}
$FilePermission = Get-FilePermissions -Path $_.FullName -ACLS $ACL -Verbose:$false
foreach ($Perm in $FilePermission) {
$Identity = Convert-Identity -Identity $Perm.Principal -Verbose:$false
[PSCustomObject] @{
FullName = $_.FullName
Extension = $_.Extension
CreationTime = $_.CreationTime
LastAccessTime = $_.LastAccessTime
LastWriteTime = $_.LastWriteTime
Attributes = $_.Attributes
AccessControlType = $Perm.AccessControlType # : Allow
Principal = $Identity.Name # : BUILTIN\Administrators
PrincipalSid = $Identity.SID
PrincipalType = $Identity.Type
FileSystemRights = $Perm.FileSystemRights # : FullControl
IsInherited = $Perm.IsInherited # : True
FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol)
}
}
} else {
[PSCustomObject] @{
FullName = $_.FullName
Extension = $_.Extension
CreationTime = $_.CreationTime
LastAccessTime = $_.LastAccessTime
LastWriteTime = $_.LastWriteTime
Attributes = $_.Attributes
Owner = $IdentityOwner.Name
OwnerSid = $IdentityOwner.SID
OwnerType = $IdentityOwner.Type
FullNameOnSysVol = $_.FullName.Replace($Path, $PathOnSysvol)
}
}
}
}
$FilesAll
}
+60 -3
View File
@@ -1,10 +1,54 @@
function Get-GPOZaurrOwner {
<#
.SYNOPSIS
Gets owners of GPOs from Active Directory and SYSVOL
.DESCRIPTION
Gets owners of GPOs from Active Directory and SYSVOL
.PARAMETER GPOName
Name of GPO. By default all GPOs are returned
.PARAMETER GPOGuid
GUID of GPO. By default all GPOs are returned
.PARAMETER IncludeSysvol
Includes Owner from SYSVOL as well
.PARAMETER SkipBroken
Doesn't display GPOs that have no SYSVOL content (orphaned GPOs)
.PARAMETER Forest
Target different Forest
.PARAMETER ExcludeDomains
Exclude domain from search, by default whole forest is scanned
.PARAMETER IncludeDomains
Include only specific domains, by default whole forest is scanned
.PARAMETER ExtendedForestInformation
Ability to provide Forest Information from another command to speed up processing
.PARAMETER ADAdministrativeGroups
Ability to provide AD Administrative Groups from another command to speed up processing
.EXAMPLE
Get-GPOZaurrOwner -Verbose -IncludeSysvol
.EXAMPLE
Get-GPOZaurrOwner -Verbose -IncludeSysvol -SkipBroken
.NOTES
General notes
#>
[cmdletbinding(DefaultParameterSetName = 'Default')]
param(
[Parameter(ParameterSetName = 'GPOName')][string] $GPOName,
[Parameter(ParameterSetName = 'GPOGUID')][alias('GUID', 'GPOID')][string] $GPOGuid,
[switch] $IncludeSysvol,
[switch] $SkipBroken,
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
@@ -17,6 +61,7 @@
if (-not $ADAdministrativeGroups) {
$ADAdministrativeGroups = Get-ADADministrativeGroups -Type DomainAdmins, EnterpriseAdmins -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
}
$Count = 0
}
Process {
$getGPOZaurrADSplat = @{
@@ -32,8 +77,9 @@
}
$Objects = Get-GPOZaurrAD @getGPOZaurrADSplat
foreach ($_ in $Objects) {
Write-Verbose "Get-GPOZaurrOwner - Processing GPO: $($_.DisplayName) from domain: $($_.DomainName)"
$ACL = Get-ADACLOwner -ADObject $_.GPODistinguishedName -Resolve -ADAdministrativeGroups $ADAdministrativeGroups
$Count++
Write-Verbose "Get-GPOZaurrOwner - Processing GPO [$Count/$($Objects.Count)]: $($_.DisplayName) from domain: $($_.DomainName)"
$ACL = Get-ADACLOwner -ADObject $_.GPODistinguishedName -Resolve -ADAdministrativeGroups $ADAdministrativeGroups -Verbose:$false
$Object = [ordered] @{
DisplayName = $_.DisplayName
DomainName = $_.DomainName
@@ -43,12 +89,23 @@
OwnerType = $ACL.OwnerType
}
if ($IncludeSysvol) {
$FileOwner = Get-FileOwner -JustPath -Path $_.Path -Resolve
$FileOwner = Get-FileOwner -JustPath -Path $_.Path -Resolve -Verbose:$false
$Object['SysvolOwner'] = $FileOwner.OwnerName
$Object['SysvolSid'] = $FileOwner.OwnerSid
$Object['SysvolType'] = $FileOwner.OwnerType
$Object['SysvolPath'] = $_.Path
$Object['IsOwnerConsistent'] = if ($ACL.OwnerName -eq $FileOwner.OwnerName) { $true } else { $false }
$Object['IsOwnerAdministrative'] = if ($Object['SysvolType'] -eq 'Administrative' -and $Object['OwnerType'] -eq 'Administrative') { $true } else { $false }
if (Test-Path -LiteralPath $Object['SysvolPath']) {
$Object['SysvolExists'] = $true
} else {
$Object['SysvolExists'] = $false
}
} else {
$Object['IsOwnerAdministrative'] = if ($Object['OwnerType'] -eq 'Administrative') { $true } else { $false }
}
if ($SkipBroken -and $Object['SysvolExists'] -eq $false) {
continue
}
$Object['DistinguishedName'] = $_.GPODistinguishedName
[PSCUstomObject] $Object
+28 -12
View File
@@ -16,6 +16,8 @@
}
Process {
foreach ($Domain in $ForestInformation.Domains) {
$TimeLog = Start-TimeLog
Write-Verbose "Get-GPOZaurrPermissionConsistency - Starting process for $Domain"
$QueryServer = $ForestInformation['QueryServers'][$Domain]['HostName'][0]
if ($GPOName) {
$getGPOSplat = @{
@@ -39,31 +41,43 @@
ErrorAction = 'SilentlyContinue'
}
}
Get-GPO @getGPOSplat | ForEach-Object -Process {
$GroupPolicies = Get-GPO @getGPOSplat
$Count = 0
$GroupPolicies | ForEach-Object -Process {
$GPO = $_
$Count++
Write-Verbose "Get-GPOZaurrPermissionConsistency - Processing [$($_.DomainName)]($Count/$($GroupPolicies.Count)) $($_.DisplayName)"
try {
$IsConsistent = $_.IsAclConsistent()
$ErrorMessage = ''
} catch {
$ErrorMessage = $_.Exception.Message
Write-Warning "Get-GPOZaurrPermissionConsistency - Failed to get consistency: $($_.Exception.Message)."
Write-Warning "Get-GPOZaurrPermissionConsistency - Processing $($GPO.DisplayName) / $($GPO.DomainName) failed to get consistency with error: $($_.Exception.Message)."
$IsConsistent = 'Not available'
}
$SysVolpath = -join ('\\', $Domain, '\sysvol\', $Domain, '\Policies\{', $_.ID.GUID, '}')
if ($VerifyInheritance) {
$FolderPermissions = Get-WinADSharePermission -Path $SysVolpath
if ($FolderPermissions) {
[Array] $NotInheritedPermissions = foreach ($File in $FolderPermissions) {
if ($File.Path -ne $SysVolpath -and $File.IsInherited -eq $false) {
$File
if ($IsConsistent -eq $true) {
$FolderPermissions = Get-WinADSharePermission -Path $SysVolpath -Verbose:$false
if ($FolderPermissions) {
[Array] $NotInheritedPermissions = foreach ($File in $FolderPermissions) {
if ($File.Path -ne $SysVolpath -and $File.IsInherited -eq $false) {
$File
}
}
if ($NotInheritedPermissions.Count -eq 0) {
$ACLConsistentInside = $true
} else {
$ACLConsistentInside = $false
}
}
if ($NotInheritedPermissions.Count -eq 0) {
$ACLConsistentInside = $true
} else {
$ACLConsistentInside = $false
$ACLConsistentInside = 'Not available'
$NotInheritedPermissions = $null
}
} else {
$ACLConsistentInside = 'Not available'
# Since top level permissions are inconsistent we don't even try to asses inside permissions
$ACLConsistentInside = $IsConsistent
$NotInheritedPermissions = $null
}
}
$Object = [ordered] @{
@@ -116,6 +130,8 @@
}
}
}
$TimeEnd = Stop-TimeLog -Time $TimeLog -Option OneLiner
Write-Verbose "Get-GPOZaurrPermissionConsistency - Finishing process for $Domain (Time to process: $TimeEnd)"
}
}
End {
+9 -44
View File
@@ -6,7 +6,8 @@
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation
[System.Collections.IDictionary] $ExtendedForestInformation,
[switch] $SkipNames
)
Begin {
$ForestInformation = Get-WinADForestDetails -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation -Extended
@@ -23,9 +24,8 @@
ADRightsAsArray = $true
ResolveTypes = $true
}
$GPOPermissionsGlobal = Get-ADACL @getADACLSplat #-Verbose
$GPOs = Get-ADObject -SearchBase "CN=Policies,CN=System,$DomainDistinguishedName" -SearchScope OneLevel -Filter * -Properties DisplayName -Server $QueryServer
$GPOPermissionsGlobal = Get-ADACL @getADACLSplat -Verbose:$false
$GPOs = Get-ADObject -SearchBase "CN=Policies,CN=System,$DomainDistinguishedName" -SearchScope OneLevel -Filter * -Properties DisplayName -Server $QueryServer -Verbose:$false
foreach ($Permission in $GPOPermissionsGlobal) {
$CustomPermission = foreach ($_ in $Permission.ActiveDirectoryRights) {
if ($_ -in 'WriteDACL', 'WriteOwner', 'GenericAll' ) {
@@ -43,7 +43,7 @@
if ($IncludePermissionType.Count -gt 0 -and $SinglePermission -notin $IncludePermissionType) {
continue
}
[PSCustomObject] @{
$OutputEntry = [ordered] @{
PrincipalName = $Permission.Principal
Permission = $SinglePermission
PermissionType = $Permission.AccessControlType
@@ -51,49 +51,14 @@
PrincipalObjectClass = $Permission.PrincipalObjectType
PrincipalDomainName = $Permission.PrincipalObjectDomain
PrincipalSid = $Permission.PrincipalObjectSid
DomainName = $Domain
GPOCount = $GPOs.Count
GPONames = $GPOs.DisplayName
DomainName = $Domain
}
}
<#
if ($Permission.ActiveDirectoryRights | ForEach-Object {
$_
}) {
[PSCustomObject] @{
PrincipalName = $Permission.Principal
Permission = 'GpoCustomOwner'
PermissionType = $Permission.AccessControlType
PrincipalSidType = $Permission.PrincipalType
PrincipalObjectClass = $Permission.PrincipalObjectType
PrincipalDomainName = $Permission.PrincipalObjectDomain
PrincipalSid = $Permission.PrincipalObjectSid
GPOCount = 'N/A'
GPONames = -join ("All-", $Domain.ToUpper())
DomainName = $Domain
if (-not $SkipNames) {
$OutputEntry['GPONames'] = $GPOs.DisplayName
}
[PSCustomObject] $OutputEntry
}
if ($Permission.ActiveDirectoryRights | ForEach-Object {
$_ -in 'CreateChild', 'GenericAll'
}) {
[PSCustomObject] @{
PrincipalName = $Permission.Principal
Permission = 'GpoCustomCreate'
PermissionType = $Permission.AccessControlType
PrincipalSidType = $Permission.PrincipalType
PrincipalObjectClass = $Permission.PrincipalObjectType
PrincipalDomainName = $Permission.PrincipalObjectDomain
PrincipalSid = $Permission.PrincipalObjectSid
GPOCount = 'N/A'
GPONames = -join ("All-", $Domain.ToUpper())
DomainName = $Domain
}
}
#>
}
}
}
+121
View File
@@ -0,0 +1,121 @@
function Invoke-GPOZaurr {
[alias('Show-GPOZaurr', 'Show-GPO')]
[cmdletBinding()]
param(
[string] $FilePath,
[string[]] $Type,
[switch] $PassThru,
[switch] $HideHTML
)
Reset-GPOZaurrStatus # This makes sure types are at it's proper status
$Script:Reporting = [ordered] @{}
# Provide version check for easy use
$GPOZaurrVersion = Get-Command -Name 'Invoke-GPOZaurr' -ErrorAction SilentlyContinue
[Array] $GitHubReleases = (Get-GitHubLatestRelease -Url "https://api.github.com/repos/evotecit/GpoZaurr/releases" -Verbose:$false)
$LatestVersion = $GitHubReleases[0]
if (-not $LatestVersion.Errors) {
if ($GPOZaurrVersion.Version -eq $LatestVersion.Version) {
$Script:Reporting['Version'] = "Current/Latest: $($LatestVersion.Version) at $($LatestVersion.PublishDate)"
} elseif ($GPOZaurrVersion.Version -lt $LatestVersion.Version) {
$Script:Reporting['Version'] = "Current: $($GPOZaurrVersion.Version), Published: $($LatestVersion.Version) at $($LatestVersion.PublishDate). Update?"
} elseif ($GPOZaurrVersion.Version -gt $LatestVersion.Version) {
$Script:Reporting['Version'] = "Current: $($GPOZaurrVersion.Version), Published: $($LatestVersion.Version) at $($LatestVersion.PublishDate). Lucky you!"
}
} else {
$Script:Reporting['Version'] = "GPOZaurr Current: $($GPOZaurrVersion.Version)"
}
Write-Color '[i]', "[GPOZaurr] ", 'Version', ' [Informative] ', $Script:Reporting['Version'] -Color Yellow, DarkGray, Yellow, DarkGray, Magenta
$Supported = [System.Collections.Generic.List[string]]::new()
[Array] $NotSupported = foreach ($T in $Type) {
if ($T -notin $Script:GPOConfiguration.Keys ) {
$T
} else {
$Supported.Add($T)
}
}
if ($Supported) {
Write-Color '[i]', "[GPOZaurr] ", 'Supported types', ' [Informative] ', "Chosen by user: ", ($Supported -join ', ') -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
}
if ($NotSupported) {
Write-Color '[i]', "[GPOZaurr] ", 'Not supported types', ' [Informative] ', "Following types are not supported: ", ($NotSupported -join ', ') -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
Write-Color '[i]', "[GPOZaurr] ", 'Not supported types', ' [Informative] ', "Please use one/multiple from the list: ", ($Script:GPOConfiguration.Keys -join ', ') -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
return
}
# Lets disable all current ones
if ($Type) {
foreach ($T in $Script:GPOConfiguration.Keys) {
$Script:GPOConfiguration[$T].Enabled = $false
}
# Lets enable all requested ones
foreach ($T in $Type) {
$Script:GPOConfiguration[$T].Enabled = $true
}
}
foreach ($T in $Script:GPOConfiguration.Keys) {
if ($Script:GPOConfiguration[$T].Enabled -eq $true) {
$TimeLogGPOList = Start-TimeLog
Write-Color -Text '[i]', '[Start] ', $($Script:GPOConfiguration[$T]['Name']) -Color Yellow, DarkGray, Yellow
$Script:GPOConfiguration[$T]['Data'] = & $Script:GPOConfiguration[$T]['Execute']
& $Script:GPOConfiguration[$T]['Processing']
$TimeEndGPOList = Stop-TimeLog -Time $TimeLogGPOList -Option OneLiner
Write-Color -Text '[i]', '[End ] ', $($Script:GPOConfiguration[$T]['Name']), " [Time to execute: $TimeEndGPOList]" -Color Yellow, DarkGray, Yellow, DarkGray
}
}
# Generate pretty HTML
Write-Verbose "Invoke-GPOZaurr - Generating HTML"
New-HTML -Author 'Przemysław Kłys' -TitleText 'GPOZaurr Report' {
New-HTMLTabStyle -BorderRadius 0px -TextTransform capitalize -BackgroundColorActive SlateGrey
New-HTMLSectionStyle -BorderRadius 0px -HeaderBackGroundColor Grey -RemoveShadow
New-HTMLPanelStyle -BorderRadius 0px
New-HTMLTableOption -DataStore JavaScript -BoolAsString
New-HTMLHeader {
New-HTMLSection -Invisible {
New-HTMLSection {
New-HTMLText -Text "Report generated on $(Get-Date)" -Color Blue
} -JustifyContent flex-start -Invisible
New-HTMLSection {
New-HTMLText -Text "GPOZaurr - $($Script:Reporting['Version'])" -Color Blue
} -JustifyContent flex-end -Invisible
}
}
if ($Type.Count -eq 1) {
foreach ($T in $Script:GPOConfiguration.Keys) {
if ($Script:GPOConfiguration[$T].Enabled -eq $true) {
& $Script:GPOConfiguration[$T]['Solution']
}
}
} else {
foreach ($T in $Script:GPOConfiguration.Keys) {
if ($Script:GPOConfiguration[$T].Enabled -eq $true) {
New-HTMLTab -Name $Script:GPOConfiguration[$T]['Name'] {
& $Script:GPOConfiguration[$T]['Solution']
}
}
}
}
} -Online -ShowHTML:(-not $HideHTML) -FilePath $FilePath
if ($PassThru) {
$OutputData = Export-GPOZaurr
$OutputData
}
Reset-GPOZaurrStatus # This makes sure types are at it's proper status
}
[scriptblock] $SourcesAutoCompleter = {
param($commandName, $parameterName, $wordToComplete, $commandAst, $fakeBoundParameters)
$Script:GPOConfiguration.Keys | Sort-Object | Where-Object { $_ -like "*$wordToComplete*" }
}
Register-ArgumentCompleter -CommandName Invoke-GPOZaurr -ParameterName Type -ScriptBlock $SourcesAutoCompleter
+38 -18
View File
@@ -21,11 +21,9 @@
[Parameter(ParameterSetName = 'Local')]
[switch] $FullObjects,
<#
[Parameter(ParameterSetName = 'Default')]
[Parameter(ParameterSetName = 'Local')]
[ValidateSet('HTML', 'Object', 'Excel')][string[]] $OutputType = 'Object',
[ValidateSet('HTML', 'Object')][string[]] $OutputType = 'Object',
[Parameter(ParameterSetName = 'Default')]
[Parameter(ParameterSetName = 'Local')]
@@ -34,7 +32,10 @@
[Parameter(ParameterSetName = 'Default')]
[Parameter(ParameterSetName = 'Local')]
[switch] $Open,
#>
[Parameter(ParameterSetName = 'Default')]
[Parameter(ParameterSetName = 'Local')]
[switch] $Online,
[Parameter(ParameterSetName = 'Default')]
[Parameter(ParameterSetName = 'Local')]
@@ -58,7 +59,7 @@
$Type = $Script:GPODitionary.Keys
}
if ($GPOPath) {
Write-Verbose "Invoke-GPOZaurr - Reading GPOs from $GPOPath"
Write-Verbose "Invoke-GPOZaurrContent - Reading GPOs from $GPOPath"
if (Test-Path -LiteralPath $GPOPath) {
$GPOFiles = Get-ChildItem -LiteralPath $GPOPath -Recurse -File -Filter *.xml
[Array] $GPOs = foreach ($File in $GPOFiles) {
@@ -66,7 +67,7 @@
try {
[xml] $GPORead = Get-Content -LiteralPath $File.FullName
} catch {
Write-Warning "Invoke-GPOZaurr - Couldn't process $($File.FullName) error: $($_.Exception.message)"
Write-Warning "Invoke-GPOZaurrContent - Couldn't process $($File.FullName) error: $($_.Exception.message)"
continue
}
[PSCustomObject] @{
@@ -78,11 +79,11 @@
}
}
} else {
Write-Warning "Invoke-GPOZaurr - $GPOPath doesn't exists."
Write-Warning "Invoke-GPOZaurrContent - $GPOPath doesn't exists."
return
}
} else {
Write-Verbose "Invoke-GPOZaurr - Query AD for GPOs"
Write-Verbose "Invoke-GPOZaurrContent - Query AD for GPOs"
[Array] $GPOs = Get-GPOZaurrAD -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains -ExtendedForestInformation $ExtendedForestInformation
}
# This caches single reports.
@@ -93,7 +94,7 @@
$Output['Reports'] = [ordered] @{}
$Output['CategoriesFull'] = [ordered] @{}
Write-Verbose "Invoke-GPOZaurr - Loading GPO Report to Categories"
Write-Verbose "Invoke-GPOZaurrContent - Loading GPO Report to Categories"
[Array] $GPOCategories = foreach ($GPO in $GPOs) {
if ($GPOPath) {
$GPOOutput = $GPO.GPOOutput
@@ -114,7 +115,7 @@
# Build reports based on categories
if ($Output['CategoriesFull'].Count -gt 0) {
foreach ($Report in $Type) {
Write-Verbose "Invoke-GPOZaurr - Processing report type $Report"
Write-Verbose "Invoke-GPOZaurrContent - Processing report type $Report"
foreach ($CategoryType in $Script:GPODitionary[$Report].Types) {
$Category = $CategoryType.Category
$Settings = $CategoryType.Settings
@@ -148,7 +149,7 @@
}
}
if ($Script:GPODitionary[$Report]['CodeSingle']) {
#Write-Verbose "Invoke-GPOZaurr - Processing $Report single entry mode"
#Write-Verbose "Invoke-GPOZaurrContent - Processing $Report single entry mode"
$TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['CodeSingle']
if ($Report -in $FindRequiredSingle) {
foreach ($T in $TranslatedGpo) {
@@ -167,7 +168,7 @@
# think drive mapping - showing 1 mapping of a drive per object even if there are 50 drive mappings within 1 gpo
# this would result in 50 objects created
if ($Script:GPODitionary[$Report]['Code']) {
#Write-Verbose "Invoke-GPOZaurr - Processing $Report multi entry mode"
#Write-Verbose "Invoke-GPOZaurrContent - Processing $Report multi entry mode"
$TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['Code']
foreach ($T in $TranslatedGpo) {
$Output['Reports'][$Report].Add($T)
@@ -186,9 +187,8 @@
$Output['Reports'][$Report] = [System.Collections.Generic.List[PSCustomObject]]::new()
}
$FindReport = $ReportType.Report
Write-Verbose "Invoke-GPOZaurr - Processing reports based on other report $Report ($FindReport)"
Write-Verbose "Invoke-GPOZaurrContent - Processing reports based on other report $Report ($FindReport)"
foreach ($GPO in $TemporaryCachedSingleReports['ReportsSingle'][$FindReport]) {
Write-Verbose "Invoke-GPOZaurr - Processing $Report"
$TranslatedGpo = Invoke-Command -ScriptBlock $Script:GPODitionary[$Report]['CodeReport']
foreach ($T in $TranslatedGpo) {
$Output['Reports'][$Report].Add($T)
@@ -221,16 +221,36 @@
#$Output['PoliciesTotal'] = $Output.Reports.Policies.PolicyCategory | Group-Object | Select-Object Name, Count | Sort-Object -Property Count -Descending
if (-not $SkipCleanup) {
Write-Verbose "Invoke-GPOZaurr - Cleaning up output"
Write-Verbose "Invoke-GPOZaurrContent - Cleaning up output"
Remove-EmptyValue -Hashtable $Output -Recursive
}
if ($Extended) {
$Output
} else {
if ($Output.Reports) {
$Output.Reports
if ($OutputType -eq 'Object') {
$Output.Reports
}
if ($OutputType -eq 'HTML') {
if (-not $OutputPath) {
$OutputPath = Get-FileName -Extension 'html' -Temporary
Write-Warning "Invoke-GPOZaurrContent - OutputPath not given. Using $OutputPath"
}
Write-Verbose "Invoke-GPOZaurrContent - Generating HTML output"
New-HTML {
New-HTMLSectionStyle -BorderRadius 0px -HeaderBackGroundColor Grey -RemoveShadow
New-HTMLTabStyle -BorderRadius 0px -TextTransform capitalize -BackgroundColorActive SlateGrey
New-HTMLTableOption -DataStore JavaScript
foreach ($Key in $Output.Reports.Keys) {
New-HTMLTab -Name $Key {
Write-Verbose "Invoke-GPOZaurrContent - Generating HTML Table for $Key"
New-HTMLTable -DataTable $Output.Reports[$Key] -Filtering -Title $Key
}
}
} -FilePath $OutputPath -ShowHTML:$Open -Online:$Online
}
} else {
Write-Warning "Invoke-GPOZaurr - There was no data output for requested types."
Write-Warning "Invoke-GPOZaurrContent - There was no data output for requested types."
}
}
}
@@ -240,4 +260,4 @@
$Script:GPODitionary.Keys | Sort-Object | Where-Object { $_ -like "*$wordToComplete*" }
}
Register-ArgumentCompleter -CommandName Invoke-GPOZaurr -ParameterName Type -ScriptBlock $SourcesAutoCompleter
Register-ArgumentCompleter -CommandName Invoke-GPOZaurrContent -ParameterName Type -ScriptBlock $SourcesAutoCompleter
@@ -1,4 +1,5 @@
function Remove-GPOZaurrOrphaned {
function Remove-GPOZaurrBroken {
[alias('Remove-GPOZaurrOrphaned')]
[cmdletBinding(SupportsShouldProcess)]
param(
[ValidateSet('SYSVOL', 'AD')][string[]] $Type = @('SYSVOL', 'AD'),
@@ -33,41 +34,41 @@
}
} | Select-Object | Select-Object -First $LimitProcessing | ForEach-Object {
if ($_.Status -eq 'Not available in AD') {
Write-Verbose "Remove-GPOZaurrOrphaned - Processing $($_.Path)"
Write-Verbose "Remove-GPOZaurrBroken - Processing $($_.Path)"
if ($BackupFinalPath) {
Try {
Write-Verbose "Remove-GPOZaurrOrphaned - Backing up $($_.Path)"
Write-Verbose "Remove-GPOZaurrBroken - Backing up $($_.Path)"
Copy-Item -LiteralPath $_.Path -Recurse -Destination $BackupFinalPath -ErrorAction Stop
$BackupWorked = $true
} catch {
Write-Warning "Remove-GPOZaurrOrphaned - Error backing up error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Error backing up error: $($_.Exception.Message)"
$BackupWorked = $false
}
}
if ($BackupWorked -or $BackupFinalPath -eq '') {
Write-Verbose "Remove-GPOZaurrOrphaned - Deleting $($_.Path)"
Write-Verbose "Remove-GPOZaurrBroken - Deleting $($_.Path)"
try {
Remove-Item -Recurse -Force -LiteralPath $_.Path
} catch {
Write-Warning "Remove-GPOZaurrOrphaned - Failed to remove file $($_.Path): $($_.Exception.Message)."
Write-Warning "Remove-GPOZaurrBroken - Failed to remove file $($_.Path): $($_.Exception.Message)."
}
}
} elseif ($_.Status -eq 'Not available on SYSVOL') {
try {
$ExistingObject = Get-ADObject -Identity $_.DistinguishedName -Server $_.DomainName -ErrorAction Stop
} catch {
Write-Warning "Remove-GPOZaurrOrphaned - Error getting $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Error getting $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
$ExistingObject = $null
}
if ($ExistingObject -and $ExistingObject.ObjectClass -eq 'groupPolicyContainer') {
Write-Verbose "Remove-GPOZaurrOrphaned - Removing DN: $($_.DistinguishedName) / ObjectClass: $($ExistingObject.ObjectClass)"
Write-Verbose "Remove-GPOZaurrBroken - Removing DN: $($_.DistinguishedName) / ObjectClass: $($ExistingObject.ObjectClass)"
try {
Remove-ADObject -Server $_.DomainName -Identity $_.DistinguishedName -Recursive -Confirm:$false
} catch {
Write-Warning "Remove-GPOZaurrOrphaned - Failed to remove $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Failed to remove $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
}
} else {
Write-Warning "Remove-GPOZaurrOrphaned - DistinguishedName $($_.DistinguishedName) not found or ObjectClass is not groupPolicyContainer ($($ExistingObject.ObjectClass))"
Write-Warning "Remove-GPOZaurrBroken - DistinguishedName $($_.DistinguishedName) not found or ObjectClass is not groupPolicyContainer ($($ExistingObject.ObjectClass))"
}
}
}
+25
View File
@@ -0,0 +1,25 @@
function Remove-GPOZaurrDuplicateObject {
[cmdletBinding(SupportsShouldProcess)]
param(
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation
)
$getGPOZaurrDuplicateObjectSplat = @{
Forest = $Forest
IncludeDomains = $IncludeDomains
ExcludeDomains = $ExcludeDomains
ExtendedForestInformation = $ExtendedForestInformation
}
$DuplicateGpoObjects = Get-GPOZaurrDuplicateObject @getGPOZaurrDuplicateObjectSplat
foreach ($Duplicate in $DuplicateGpoObjects) {
try {
Remove-ADObject -Identity $_.ObjectGUID -Recursive -ErrorAction Stop -Server $Duplicate.DomainName
} catch {
Write-Warning "Remove-GPOZaurrDuplicateObject - Deleting $($Duplicate.ConflictDN) / $($Duplicate.DomainName) via GUID: $($Duplicate.ObjectGUID) failed with error: $($_.Exception.Message)"
}
}
}
+36
View File
@@ -0,0 +1,36 @@
function Repair-GPOZaurrNetLogonOwner {
[cmdletBinding(SupportsShouldProcess)]
param(
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains,
[System.Collections.IDictionary] $ExtendedForestInformation,
[string] $Principal = 'S-1-5-32-544',
[int] $LimitProcessing = [int32]::MaxValue
)
$Identity = Convert-Identity -Identity $Principal -Verbose:$false
if ($Identity.Error) {
Write-Warning "Repair-GPOZaurrNetLogonOwner - couldn't convert Identity $Principal to desired name. Error: $($Identity.Error)"
return
}
$Principal = $Identity.Name
$getGPOZaurrNetLogonSplat = @{
OwnerOnly = $true
Forest = $Forest
IncludeDomains = $IncludeDomains
ExcludeDomains = $ExcludeDomains
ExtendedForestInformation = $ExtendedForestInformation
}
Get-GPOZaurrNetLogon @getGPOZaurrNetLogonSplat | Select-Object -First $LimitProcessing | Where-Object {
if ($_.OwnerSid -ne 'S-1-5-32-544') {
$_
}
} | ForEach-Object {
if ($PSCmdlet.ShouldProcess($_.FullName, "Setting NetLogon Owner to $($Principal)")) {
Set-FileOwner -JustPath -Path $_.FullName -Owner $Principal -Verbose:$true -WhatIf:$WhatIfPreference
}
}
}
+17 -14
View File
@@ -1,10 +1,10 @@
function Set-GPOZaurrOwner {
<#
.SYNOPSIS
Short description
Sets GPO Owner to Domain Admins or other choosen account
.DESCRIPTION
Long description
Sets GPO Owner to Domain Admins or other choosen account. GPO Owner is set in AD and SYSVOL unless specified otherwise. If account doesn't require change, no change is done.
.PARAMETER Type
Unknown - finds unknown Owners and sets them to Administrative (Domain Admins) or chosen principal
@@ -12,34 +12,34 @@
NotAdministrative - combination of Unknown/NotMatching and NotAdministrative - replace with chosen principal or Domain Admins if not specified
All - if Owner is known it checks if it's Administrative, if it sn't it fixes that. If owner is unknown it fixes it
.PARAMETER GPOName
Parameter description
Name of GPO. By default all GPOs are targetted
.PARAMETER GPOGuid
Parameter description
GUID of GPO. By default all GPOs are targetted
.PARAMETER Forest
Parameter description
Target different Forest
.PARAMETER ExcludeDomains
Parameter description
Exclude domain from search, by default whole forest is scanned
.PARAMETER IncludeDomains
Parameter description
Include only specific domains, by default whole forest is scanned
.PARAMETER ExtendedForestInformation
Parameter description
Ability to provide Forest Information from another command to speed up processing
.PARAMETER Principal
Parameter description
.PARAMETER SkipSysvol
Parameter description
Set GPO Owner only in Active Directory. By default GPO Owner is being set in both places
.PARAMETER LimitProcessing
Parameter description
Allows to specify maximum number of items that will be fixed in a single run. It doesn't affect amount of GPOs processed
.EXAMPLE
An example
Set-GPOZaurrOwner -Type All -Verbose -WhatIf -LimitProcessing 2
.NOTES
General notes
@@ -92,13 +92,16 @@
ExtendedForestInformation = $ExtendedForestInformation
ADAdministrativeGroups = $ADAdministrativeGroups
Verbose = $VerbosePreference
SkipBroken = $true
}
if ($GPOName) {
$getGPOZaurrOwnerSplat['GPOName'] = $GPOName
} elseif ($GPOGuid) {
$getGPOZaurrOwnerSplat['GPOGuid'] = $GPOGUiD
}
$Count = 0
Get-GPOZaurrOwner @getGPOZaurrOwnerSplat | Where-Object {
$Count++
if ($_.Owner) {
$AdministrativeGroup = $ADAdministrativeGroups['ByNetBIOS']["$($_.Owner)"]
} else {
@@ -161,15 +164,15 @@
}
if ($Action -eq 'OnlyGPO') {
Write-Verbose "Set-GPOZaurrOwner - Changing GPO: $($GPO.DisplayName) from domain: $($GPO.DomainName) from owner $($GPO.Owner) (SID: $($GPO.OwnerSID)) to $DefaultPrincipal"
Set-ADACLOwner -ADObject $GPO.DistinguishedName -Principal $DefaultPrincipal -Verbose:$false -WhatIf:$WhatIfPreference
Set-ADACLOwner -ADObject $GPO.DistinguishedName -Principal $DefaultPrincipal -Verbose:$false -WhatIf:$WhatIfPreference
} elseif ($Action -eq 'OnlyFileSystem') {
if (-not $SkipSysvol) {
Write-Verbose "Set-GPOZaurrOwner - Changing Sysvol Owner GPO: $($GPO.DisplayName) from domain: $($GPO.DomainName) from owner $($GPO.SysvolOwner) (SID: $($GPO.SysvolSid)) to $DefaultPrincipal"
Set-FileOwner -JustPath -Path $GPO.SysvolPath -Owner $DefaultPrincipal -Verbose:$true -WhatIf:$WhatIfPreference
Set-FileOwner -JustPath -Path $GPO.SysvolPath -Owner $DefaultPrincipal -Verbose:$true -WhatIf:$WhatIfPreference
}
} else {
Write-Verbose "Set-GPOZaurrOwner - Changing GPO: $($GPO.DisplayName) from domain: $($GPO.DomainName) from owner $($GPO.Owner) (SID: $($GPO.OwnerSID)) to $DefaultPrincipal"
Set-ADACLOwner -ADObject $GPO.DistinguishedName -Principal $DefaultPrincipal -Verbose:$false -WhatIf:$WhatIfPreference
Set-ADACLOwner -ADObject $GPO.DistinguishedName -Principal $DefaultPrincipal -Verbose:$false -WhatIf:$WhatIfPreference
if (-not $SkipSysvol) {
Write-Verbose "Set-GPOZaurrOwner - Changing Sysvol Owner GPO: $($GPO.DisplayName) from domain: $($GPO.DomainName) from owner $($GPO.SysvolOwner) (SID: $($GPO.SysvolSid)) to $DefaultPrincipal"
Set-FileOwner -JustPath -Path $GPO.SysvolPath -Owner $DefaultPrincipal -Verbose:$true -WhatIf:$WhatIfPreference
+36
View File
@@ -49,6 +49,42 @@ That's it. Whenever there's a new version, you run the command, and you can enjo
## Changelog
- 0.0.72 - 6.11.2020
- Improved `Invoke-GPOZaurr` (WIP)
- 0.0.71 - 3.11.2020
- Improved `Invoke-GPOZaurr` (WIP)
- 0.0.70 - 29.10.2020
- Added `Get-GPOZaurrDuplicateObject`
- Added `Remove-GPOZaurrDuplicateObject`
- 0.0.69 - 29.10.2020
- Improved `Invoke-GPOZaurr` (WIP)
- Improved `Get-GPOZaurrNetLogon`
- Improved `Get-GPOZaurrOwner`
- Improved `Set-GPOZaurrOwner`
- Added `Repair-GPOZaurrNetLogonOwner`
- Improved `Invoke-GPOZaurr` (WIP)
- 0.0.68 - 28.10.2020
- Renamed `Show-GPOZaurr` to `Invoke-GPOZaurr`
- Renamed `Invoke-GPOZaurr` to `Invoke-GPOZaurrContent`
- Improvements to `Get-GPOZaurrPermissionConsistency` - don't check for inherited permissions if top level ones are inconsistent
- Improved `Invoke-GPOZaurr` (WIP)
- 0.0.67 - 22.10.2020
- Improved `Show-GPOZaurr` (WIP)
- 0.0.66 - 22.10.2020
- Improved `Show-GPOZaurr` (WIP)
- 0.0.65 - 22.10.2020
- Improved `Show-GPOZaurr` (WIP)
- 0.0.64 - 21.10.2020
- Renamed `Remove-GPOZaurrOrphaned` to `Remove-GPOZaurrBroken` keeping it as an alias
- Renamed `Get-GPOZaurrSysvol` to `Get-GPOZaurrBroken` keeping it as an alias
- Improved `Show-GPOZaurr` (WIP)
- 0.0.63 - 19.10.2020
- Renamed `Invoke-GPOZaurrContent` back to `Invoke-GPOZaurr`
- Added `Show-GPOZaurr` (WIP)
- Added `OutputType`,`OutputType`,`Open`,`Online` parameters to `Invoke-GPOZaurr`
- Added `Get-GPOZaurrNetLogon`
- Improved `Get-GPOZaurrOwner`
- Fixes `Get-GPOZaurrSysvol`
- 0.0.62 - 14.10.2020
- Renamed `Invoke-GPOZaurr` to `Invoke-GPOZaurrContent` - I want to use `Invoke-GPOZaurr` for something else
- Improvements to `Get-GPOZaurrPermissionConsistency` for GPOs without SYSVOL to be reported properly