Compare commits

..

7 Commits

Author SHA1 Message Date
Przemyslaw Klys 807ea420b0 Support for Forest/IncludeDomains/ExcludeDomains 2020-11-18 19:43:16 +01:00
Przemyslaw Klys 9cd28b11ea Improve Remove-GPOZaurrBroken 2020-11-18 18:42:43 +01:00
Przemyslaw Klys 5fb48b994b Update readme/PSD1 2020-11-18 18:42:02 +01:00
Przemyslaw Klys 3cfae42cc1 Update 2020-11-17 10:33:51 +01:00
Przemyslaw Klys fb922d7836 Update 2020-11-17 00:06:48 +01:00
Przemyslaw Klys fb7dfdc4b1 Update 2020-11-17 00:06:35 +01:00
Przemyslaw Klys 9d18f4d11a Update Readme/PSD1 2020-11-17 00:06:20 +01:00
22 changed files with 643 additions and 238 deletions
+2 -2
View File
@@ -8,7 +8,7 @@
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-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-GPOZaurrPermissionIssue', 'Get-GPOZaurrPermissionRoot', 'Get-GPOZaurrPermissionSummary', 'Get-GPOZaurrSysvolDFSR', 'Get-GPOZaurrWMI', 'Invoke-GPOZaurr', 'Invoke-GPOZaurrContent', 'Invoke-GPOZaurrPermission', 'Invoke-GPOZaurrSupport', 'New-GPOZaurrWMI', 'Optimize-GPOZaurr', '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.84'
ModuleVersion = '0.0.86'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
@@ -26,7 +26,7 @@
ModuleName = 'ADEssentials'
Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
}, @{
ModuleVersion = '0.0.121'
ModuleVersion = '0.0.122'
ModuleName = 'PSWriteHTML'
Guid = 'a7bdf640-f5cb-4acf-9de0-365b322d245c'
}, 'CimCmdlets', 'Microsoft.PowerShell.Management', 'Microsoft.PowerShell.Utility', 'Microsoft.PowerShell.Security')
+1 -1
View File
@@ -4,7 +4,7 @@
ActionRequired = $null
Data = $null
Execute = {
Invoke-GPOZaurrContent
Invoke-GPOZaurrContent -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
@@ -4,7 +4,7 @@
ActionRequired = $null
Data = $null
Execute = {
Get-GPOZaurrInheritance -IncludeBlockedObjects -OnlyBlockedInheritance
Get-GPOZaurrInheritance -IncludeBlockedObjects -OnlyBlockedInheritance -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+3 -1
View File
@@ -3,7 +3,9 @@
Enabled = $true
ActionRequired = $null
Data = $null
Execute = { Get-GPOZaurrPermissionConsistency -Type All -VerifyInheritance }
Execute = {
Get-GPOZaurrPermissionConsistency -Type All -VerifyInheritance -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
foreach ($GPO in $Script:Reporting['GPOConsistency']['Data']) {
if ($GPO.ACLConsistent -eq $true) {
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurrDuplicateObject
Get-GPOZaurrDuplicateObject -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
$Script:Reporting['GPODuplicates']['Variables']['RequireDeletion'] = $Script:Reporting['GPODuplicates']['Data'].Count
+1 -1
View File
@@ -4,7 +4,7 @@
ActionRequired = $null
Data = $null
Execute = {
Get-GPOZaurrFiles
Get-GPOZaurrFiles -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurr
Get-GPOZaurr -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
foreach ($GPO in $Script:Reporting['GPOList']['Data']) {
+259
View File
@@ -0,0 +1,259 @@
$GPOZaurrNetLogonOwners = [ordered] @{
Name = 'NetLogon Owners'
Enabled = $true
ActionRequired = $null
Data = $null
Execute = {
Get-GPOZaurrNetLogon -OwnerOnly -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
foreach ($File in $Script:Reporting['NetLogonOwners']['Data']) {
# if ($File.FileSystemRights -eq 'Owner') {
# Process Owner part of the report
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwners']++
if ($File.OwnerType -eq 'WellKnownAdministrative') {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrative']++
} elseif ($File.OwnerType -eq 'Administrative') {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrative']++
} else {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersNotAdministrative']++
}
if ($File.OwnerSid -eq 'S-1-5-32-544') {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrators']++
} elseif ($File.OwnerType -in 'WellKnownAdministrative', 'Administrative') {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrativeNotAdministrators']++
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersToFix']++
} else {
$Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersToFix']++
}
#$Script:Reporting['NetLogonPermissions']['Variables']['Owner'].Add($File)
#} else {
# Process all other part of the report
# $Script:Reporting['NetLogonPermissions']['Variables']['NonOwner'].Add($File)
# if ($File.Status -eq 'Review permission required') {
# $Script:Reporting['NetLogonPermissions']['Variables']['PermissionReviewRequired']++
# } elseif ($File.Status -eq 'Removal permission required') {
# $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequired']++
# } elseif ($File.Status -eq 'Not assesed') {
# $Script:Reporting['NetLogonPermissions']['Variables']['PermissionNotAssesed']++
# } else {
# $Script:Reporting['NetLogonPermissions']['Variables']['PermissionOK']++
# }
# }
}
if ($Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersToFix'] -gt 0) {
$Script:Reporting['NetLogonOwners']['ActionRequired'] = $true
} else {
$Script:Reporting['NetLogonOwners']['ActionRequired'] = $false
}
# if (-not $Script:Reporting['NetLogonPermissions']['ActionRequired']) {
# # if owners require fixing, we don't need to check those as we get this anyways
# # if owners don't require fixing we check permissions anyways
# if ($Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequired'] -gt 0 -or $Script:Reporting['NetLogonPermissions']['Variables']['PermissionReviewRequired'] -gt 0) {
# $Script:Reporting['NetLogonPermissions']['ActionRequired'] = $true
# } else {
# $Script:Reporting['NetLogonPermissions']['ActionRequired'] = $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()
# PermissionReviewRequired = 0
# PermissionRemovalRequired = 0
# PermissionOK = 0
# PermissionNotAssesed = 0
}
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: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwners'] -FontWeight normal, bold
# New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
# New-HTMLListItem -Text "NetLogon Owners requiring change: ", $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
# New-HTMLList -Type Unordered {
# New-HTMLListItem -Text 'Not Administrative: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
# New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $Script:Reporting['NetLogonPermissions']['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 $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
# New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
# } -Title 'NetLogon Owners' -TitleAlignment center
# }
# New-HTMLPanel {
# }
}
Summary = {
New-HTMLText -TextBlock {
"NetLogon is crucial part of Active Directory. Files stored there are available on each and every computer or server in the company. "
"Keeping those files clean and secure is very important task. "
"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/she 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: ', $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwners'] -FontWeight normal, bold
New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text "NetLogon Owners requiring change: ", $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Not Administrative: ', $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrativeNotAdministrators'] -FontWeight normal, bold
}
}
} -FontSize 10pt
New-HTMLText -Text "Follow the steps below table to get NetLogon Owners into compliant state." -FontSize 10pt
}
Solution = {
#New-HTMLTab -Name 'NetLogon Owners' {
New-HTMLSection -Invisible {
New-HTMLPanel {
& $Script:GPOConfiguration['NetLogonOwners']['Summary']
}
New-HTMLPanel {
New-HTMLChart {
New-ChartPie -Name 'Correct Owners' -Value $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonOwners']['Variables']['NetLogonOwnersToFix'] -Color Crimson
} -Title 'NetLogon Owners' -TitleAlignment center
}
}
New-HTMLSection -Name 'NetLogon File Owners' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonOwners']['Data'] -Filtering {
New-HTMLTableCondition -Name 'OwnerSid' -Value "S-1-5-32-544" -BackgroundColor LightGreen -ComparisonType string
New-HTMLTableCondition -Name 'OwnerSid' -Value "S-1-5-32-544" -BackgroundColor Salmon -ComparisonType string -Operator ne
New-HTMLTableCondition -Name 'OwnerType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq
New-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor LightGreen -ComparisonType string -Operator eq
New-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor Salmon -ComparisonType string -Operator ne
}
}
New-HTMLSection -Name 'Steps to fix NetLogon Owners ' {
New-HTMLContainer {
New-HTMLSpanStyle -FontSize 10pt {
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 NetLogonOwners
}
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 -OwnerOnly -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 {
"Alternatively for multi-domain scenario, if you have limited Domain Admin credentials to a single domain please use following command: "
}
New-HTMLCodeBlock -Code {
Repair-GPOZaurrNetLogonOwner -Verbose -WhatIf -IncludeDomains 'YourDomainYouHavePermissionsFor'
}
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. "
} -LineBreak
New-HTMLText -Text "Once happy with results please follow with command (this will start replacement of owners process): " -LineBreak -FontWeight bold
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-HTMLCodeBlock -Code {
Repair-GPOZaurrNetLogonOwner -Verbose -LimitProcessing 2
}
New-HTMLText -TextBlock {
"Alternatively for multi-domain scenario, if you have limited Domain Admin credentials to a single domain please use following command: "
}
New-HTMLCodeBlock -Code {
Repair-GPOZaurrNetLogonOwner -Verbose -LimitProcessing 2 -IncludeDomains 'YourDomainYouHavePermissionsFor'
}
}
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 NetLogonOwners
}
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
}
}
}
if ($Script:Reporting['NetLogonOwners']['WarningsAndErrors']) {
New-HTMLSection -Name 'Warnings & Errors to Review' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonOwners']['WarningsAndErrors'] -Filtering {
New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
}
}
}
#}
#New-HTMLTab -Name 'NetLogon Permissions' {
# New-HTMLSection -Invisible {
# New-HTMLPanel {
# #& $Script:GPOConfiguration['NetLogonPermissions']['Summary']
# }
# New-HTMLPanel {
# #New-HTMLChart {
# # New-ChartPie -Name 'Correct Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
# # New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
# #} -Title 'NetLogon Owners' -TitleAlignment center
# }
# }
# # New-HTMLSection -Name 'NetLogon Files List' {
# # New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['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 'NetLogon Files List' {
# New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['Variables']['NonOwner'] -Filtering {
# New-HTMLTableCondition -Name 'PrincipalType' -Value "Unknown" -BackgroundColor Salmon -ComparisonType string -Operator eq -Row
# New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq -Row
# New-HTMLTableCondition -Name 'Status' -Value "Review permission required" -BackgroundColor PaleGoldenrod -ComparisonType string -Operator eq -Row
# New-HTMLTableCondition -Name 'Status' -Value "Removal permission required" -BackgroundColor Salmon -ComparisonType string -Operator eq -Row
# New-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor LightGreen -ComparisonType string -Operator eq
# }
# }
# if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) {
# New-HTMLSection -Name 'Warnings & Errors to Review' {
# New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering {
# New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
# New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
# }
# }
# }
# }
}
}
+250 -169
View File
@@ -4,212 +4,293 @@
ActionRequired = $null
Data = $null
Execute = {
Get-GPOZaurrNetLogon
Get-GPOZaurrNetLogon -SkipOwner -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'] = @{}
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReviewPerDomain'] = @{}
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReviewPerDomain'] = @{}
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredPerDomain'] = @{}
foreach ($File in $Script:Reporting['NetLogonPermissions']['Data']) {
if ($File.FileSystemRights -eq 'Owner') {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwners']++
if ($File.PrincipalType -eq 'WellKnownAdministrative') {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrative']++
} elseif ($File.PrincipalType -eq 'Administrative') {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrative']++
if (-not $Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'][$File.DomainName]) {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'][$File.DomainName] = 0
}
if (-not $Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReviewPerDomain'][$File.DomainName]) {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReviewPerDomain'][$File.DomainName] = 0
}
if (-not $Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReviewPerDomain'][$File.DomainName]) {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReviewPerDomain'][$File.DomainName] = 0
}
if (-not $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredPerDomain'][$File.DomainName]) {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredPerDomain'][$File.DomainName] = 0
}
if ($File.Status -eq 'Review permission required') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionReviewRequired']++
if ($File.FileSystemRights -like '*Modify*') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReview']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReviewPerDomain'][$File.DomainName]++
} elseif ($File.FileSystemRights -like '*Write*') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReview']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'][$File.DomainName]++
} elseif ($File.FileSystemRights -like '*FullControl*') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReview']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReviewPerDomain'][$File.DomainName]++
} else {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersNotAdministrative']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionOtherReview']++
}
if ($File.PrincipalSid -eq 'S-1-5-32-544') {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators']++
} elseif ($File.PrincipalType -in 'WellKnownAdministrative', 'Administrative') {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrativeNotAdministrators']++
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix']++
} elseif ($File.Status -eq 'Removal permission required') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequired']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredPerDomain'][$File.DomainName]++
if ($File.PrincipalObjectClass -in 'user', 'computer') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredBecauseObject']++
} else {
$Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix']++
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredBecauseUnknown']++
}
$Script:Reporting['NetLogonPermissions']['Variables']['Owner'].Add($File)
} elseif ($File.Status -eq 'Not assesed') {
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionNotAssesed']++
} else {
$Script:Reporting['NetLogonPermissions']['Variables']['NonOwner'].Add($File)
$Script:Reporting['NetLogonPermissions']['Variables']['PermissionOK']++
}
}
if ($Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -gt 0) {
if ($Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequired'] -gt 0 -or $Script:Reporting['NetLogonPermissions']['Variables']['PermissionReviewRequired'] -gt 0) {
$Script:Reporting['NetLogonPermissions']['ActionRequired'] = $true
} else {
$Script:Reporting['NetLogonPermissions']['ActionRequired'] = $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()
PermissionReviewRequired = 0
PermissionRemovalRequired = 0
PermissionOK = 0
PermissionNotAssesed = 0
PermissionWriteReview = 0
PermissionFullControlReview = 0
PermissionModifyReview = 0
PermissionOtherReview = 0
PermissionRemovalRequiredBecauseObject = 0
PermissionRemovalRequiredBecauseUnknown = 0
PermissionWriteReviewPerDomain = $null
PermissionFullControlReviewPerDomain = $null
PermissionModifyReviewPerDomain = $null
PermissionRemovalRequiredPerDomain = $null
}
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: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwners'] -FontWeight normal, bold
New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text "NetLogon Owners requiring change: ", $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Not Administrative: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $Script:Reporting['NetLogonPermissions']['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 $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
} -Title 'NetLogon Owners' -TitleAlignment center
}
New-HTMLPanel {
}
}
Summary = {
New-HTMLText -TextBlock {
"NetLogon is crucial part of Active Directory. Files stored there are available on each and every computer or server in the company. "
"Keeping those files clean and secure is very important task. "
"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/she 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. "
"Each file stored on NETLOGON has it's own permissions. "
"It's important that crucial permissions such as FullControl, Modify or Write permissions are only applied to proper, trusted groups of users. "
"Additionally permissions for FullControl, Modify or Write should not be granted to direct users or computers. Only groups are allowed! "
""
} -FontSize 10pt
New-HTMLText -Text 'Assesment overall: ' -FontSize 10pt -FontWeight bold
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'NetLogon Files in Total: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwners'] -FontWeight normal, bold
New-HTMLListItem -Text 'NetLogon BUILTIN\Administrators as Owner: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text "NetLogon Owners requiring change: ", $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -FontWeight normal, bold {
New-HTMLListItem -Text 'Permissions that look ok: ' {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Not Administrative: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersNotAdministrative'] -FontWeight normal, bold
New-HTMLListItem -Text 'Administrative, but not BUILTIN\Administrators: ', $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrativeNotAdministrators'] -FontWeight normal, bold
New-HTMLListItem -Text 'Assesed and as expected ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionOK'] -FontWeight normal, bold
New-HTMLListItem -Text 'Not assesed, but not critical (read/execute only) ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionNotAssesed'] -FontWeight normal, bold
}
}
New-HTMLListItem -Text 'Permissions requiring review:' {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Full control permissions ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReview'] -FontWeight normal, bold
New-HTMLListItem -Text 'Modify permissions ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReview'] -FontWeight normal, bold
New-HTMLListItem -Text 'Write permissions ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReview'] -FontWeight normal, bold
}
}
New-HTMLListItem -Text 'Permissions requiring removal: ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequired'] -FontWeight normal, bold {
New-HTMLList -Type Unordered {
New-HTMLListItem -Text 'Because of object type (user/computer) ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredBecauseObject'] -FontWeight normal, bold
New-HTMLListItem -Text 'Because of unknown permissions ', $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredBecauseUnknown'] -FontWeight normal, bold
}
}
} -FontSize 10pt -LineBreak
New-HTMLText -Text 'Assesment split per domain (will require permissions to fix): ' -FontSize 10pt -FontWeight bold
New-HTMLList -Type Unordered {
foreach ($Domain in $Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'].Keys) {
New-HTMLListItem -Text "$Domain requires review of ", $Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReviewPerDomain'][$Domain], " full control" -FontWeight normal, bold, normal
New-HTMLListItem -Text "$Domain requires review of ", $Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReviewPerDomain'][$Domain], " modify permission" -FontWeight normal, bold, normal
New-HTMLListItem -Text "$Domain requires review of ", $Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReviewPerDomain'][$Domain], " write permission" -FontWeight normal, bold, normal
New-HTMLListItem -Text "$Domain requires removal of ", $Script:Reporting['NetLogonPermissions']['Variables']['PermissionRemovalRequiredPerDomain'][$Domain], " permissions" -FontWeight normal, bold, normal
}
} -FontSize 10pt
New-HTMLText -Text "Follow the steps below table to get NetLogon Owners into compliant state." -FontSize 10pt
New-HTMLText -Text "Please review output in table and follow the steps below table to get NetLogon permissions in order." -FontSize 10pt
}
Solution = {
New-HTMLTab -Name 'NetLogon Owners' {
New-HTMLSection -Invisible {
New-HTMLPanel {
& $Script:GPOConfiguration['NetLogonPermissions']['Summary']
}
New-HTMLPanel {
New-HTMLChart {
New-ChartPie -Name 'Correct Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
} -Title 'NetLogon Owners' -TitleAlignment center
}
}
New-HTMLSection -Name 'NetLogon Files List' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['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 -OwnerOnly -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-HTMLTab -Name 'NetLogon Owners' {
# New-HTMLSection -Invisible {
# New-HTMLPanel {
# & $Script:GPOConfiguration['NetLogonPermissions']['Summary']
# }
# New-HTMLPanel {
# New-HTMLChart {
# New-ChartPie -Name 'Correct Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
# New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
# } -Title 'NetLogon Owners' -TitleAlignment center
# }
# }
# New-HTMLSection -Name 'NetLogon File Owners' {
# New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['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-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor LightGreen -ComparisonType string -Operator eq
# New-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor Salmon -ComparisonType string -Operator ne
# }
# }
# 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 -OwnerOnly -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-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
# }
# }
# }
# if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) {
# New-HTMLSection -Name 'Warnings & Errors to Review' {
# New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering {
# New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
# New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
# }
# }
# }
# }
#New-HTMLTab -Name 'NetLogon Permissions' {
New-HTMLSection -Invisible {
New-HTMLPanel {
& $Script:GPOConfiguration['NetLogonPermissions']['Summary']
}
if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) {
New-HTMLSection -Name 'Warnings & Errors to Review' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering {
New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
}
New-HTMLPanel {
New-HTMLChart {
New-ChartPie -Name 'Full Control requiring review' -Value $Script:Reporting['NetLogonPermissions']['Variables']['PermissionFullControlReview'] -Color Crimson
New-ChartPie -Name 'Modify requiring review' -Value $Script:Reporting['NetLogonPermissions']['Variables']['PermissionModifyReview'] -Color Plum
New-ChartPie -Name 'Write requiring review' -Value $Script:Reporting['NetLogonPermissions']['Variables']['PermissionWriteReview'] -Color LightCoral
New-ChartPie -Name 'Permissions OK' -Value $Script:Reporting['NetLogonPermissions']['Variables']['PermissionOK'] -Color LightGreen
New-ChartPie -Name 'Permissions ReadOnly/Execute' -Value $Script:Reporting['NetLogonPermissions']['Variables']['PermissionNotAssesed'] -Color Aqua
} -Title 'NetLogon Permissions' -TitleAlignment center
}
}
New-HTMLSection -Name 'NetLogon Files List' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['Data'] -Filtering {
New-HTMLTableCondition -Name 'PrincipalType' -Value "Unknown" -BackgroundColor Salmon -ComparisonType string -Operator eq -Row
New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq -Row
New-HTMLTableCondition -Name 'Status' -Value "Review permission required" -BackgroundColor PaleGoldenrod -ComparisonType string -Operator eq
New-HTMLTableCondition -Name 'Status' -Value "Removal permission required" -BackgroundColor Salmon -ComparisonType string -Operator eq -Row
New-HTMLTableCondition -Name 'Status' -Value "OK" -BackgroundColor LightGreen -ComparisonType string -Operator eq
}
}
New-HTMLSection -Name 'Steps to fix NetLogon Permissions ' {
New-HTMLContainer {
New-HTMLSpanStyle -FontSize 10pt {
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 NetLogonPermissions
}
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 -SkipOwner -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 'Remove permissions manually for non-compliant users/groups' {
New-HTMLText -Text @(
"In case of NETLOGON permissions it's impossible to tell what in a given moment for given domain should be automatically removed except for the very obvious ",
"unknown ", 'permissions. Domain Admins have to make their assesment on and remove permissions from users or groups that '
) -FontWeight normal, bold, normal
}
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 NetLogonPermissions
}
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 -Invisible {
New-HTMLPanel {
#& $Script:GPOConfiguration['NetLogonPermissions']['Summary']
}
New-HTMLPanel {
#New-HTMLChart {
# New-ChartPie -Name 'Correct Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersAdministrators'] -Color LightGreen
# New-ChartPie -Name 'Incorrect Owners' -Value $Script:Reporting['NetLogonPermissions']['Variables']['NetLogonOwnersToFix'] -Color Crimson
#} -Title 'NetLogon Owners' -TitleAlignment center
}
}
# New-HTMLSection -Name 'NetLogon Files List' {
# New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['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 'NetLogon Files List' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['Variables']['NonOwner'] -Filtering {
New-HTMLTableCondition -Name 'PrincipalType' -Value "Unknown" -BackgroundColor Salmon -ComparisonType string -Operator eq -Row
New-HTMLTableCondition -Name 'PrincipalType' -Value "WellKnownAdministrative" -BackgroundColor LightGreen -ComparisonType string -Operator eq -Row
New-HTMLTableCondition -Name 'Status' -Value "Review Required" -BackgroundColor PaleGoldenrod -ComparisonType string -Operator eq -Row
}
}
if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) {
New-HTMLSection -Name 'Warnings & Errors to Review' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering {
New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
}
if ($Script:Reporting['NetLogonPermissions']['WarningsAndErrors']) {
New-HTMLSection -Name 'Warnings & Errors to Review' {
New-HTMLTable -DataTable $Script:Reporting['NetLogonPermissions']['WarningsAndErrors'] -Filtering {
New-HTMLTableCondition -Name 'Type' -Value 'Warning' -BackgroundColor SandyBrown -ComparisonType string -Row
New-HTMLTableCondition -Name 'Type' -Value 'Error' -BackgroundColor Salmon -ComparisonType string -Row
}
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
ActionRequired = $null
Data = $null
Execute = {
Get-GPOZaurrBroken
Get-GPOZaurrBroken -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
$Script:Reporting['GPOOrphans']['Variables']['ToBeDeletedPerDomain'] = @{}
+3 -1
View File
@@ -3,7 +3,9 @@
Enabled = $true
ActionRequired = $null
Data = $null
Execute = { Get-GPOZaurrOwner -IncludeSysvol }
Execute = {
Get-GPOZaurrOwner -IncludeSysvol -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
# Create Per Domain Variables
$Script:Reporting['GPOOwners']['Variables']['RequiresDiffFixPerDomain'] = @{}
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPassword
Get-GPOZaurrPassword -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPermission -Type All -IncludePermissionType GpoEditDeleteModifySecurity, GpoEdit, GpoCustom #-IncludeOwner
Get-GPOZaurrPermission -Type All -IncludePermissionType GpoEditDeleteModifySecurity, GpoEdit, GpoCustom -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+1 -1
View File
@@ -5,7 +5,7 @@
Data = $null
Execute = {
[ordered] @{
Permissions = Get-GPOZaurrPermission -Type AuthenticatedUsers -ReturnSecurityWhenNoData
Permissions = Get-GPOZaurrPermission -Type AuthenticatedUsers -ReturnSecurityWhenNoData -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
Issues = Get-GPOZaurrPermissionIssue
}
}
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurrPermissionRoot -SkipNames
Get-GPOZaurrPermissionRoot -SkipNames -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+1 -1
View File
@@ -4,7 +4,7 @@
Action = $null
Data = $null
Execute = {
Get-GPOZaurrLegacyFiles
Get-GPOZaurrLegacyFiles -Forest $Forest -IncludeDomains $IncludeDomains -ExcludeDomains $ExcludeDomains
}
Processing = {
+1
View File
@@ -11,6 +11,7 @@
GPOFiles = $GPOZaurrFiles
GPOBlockedInheritance = $GPOZaurrBlockedInheritance
GPOAnalysis = $GPOZaurrAnalysis
NetLogonOwners = $GPOZaurrNetLogonOwners
NetLogonPermissions = $GPOZaurrNetLogonPermissions
SysVolLegacyFiles = $GPOZaurrSysVolLegacyFiles
}
+9
View File
@@ -129,6 +129,9 @@
} elseif ($_.Extension -eq '.adm') {
$SuggestedAction = 'Consider deleting'
$SuggestedActionComment = 'Most likely legacy ADM files'
} elseif ($_.Name -eq 'Thumbs.db') {
$SuggestedAction = 'Consider deleting'
$SuggestedActionComment = 'Most likely database files to store image thumbnails on Windows systems.'
}
if (-not $SuggestedAction) {
$FullPathAdmFiles = [System.IO.Path]::Combine($GPO.Path, 'Adm\admfiles.ini')
@@ -217,6 +220,12 @@
}
}
}
if (-not $SuggestedAction) {
if ($_.Name -eq 'Thumbs.db') {
$SuggestedAction = 'Consider deleting'
$SuggestedActionComment = 'Most likely database files to store image thumbnails on Windows systems.'
}
}
if (-not $SuggestedAction) {
foreach ($FullName in @('*backup*', '*Delete*', '*Obsoleet*', '*Obsolete*', '*Archive*')) {
if ($_.FullName -like $FullName) {
+67 -37
View File
@@ -23,70 +23,100 @@
} catch {
Write-Warning "Get-GPOZaurrNetLogon - ACL reading failed for $($File.FullName) with error $($_.Exception.Message) ($($_.CategoryInfo.Reason))"
}
if ($ACL.Owner) {
$IdentityOwner = Convert-Identity -Identity $ACL.Owner -Verbose:$false
} else {
$IdentityOwner = [PSCustomObject] @{ SID = ''; Type = 'Uknown' }
}
#if ($ACL.Owner) {
$IdentityOwner = Convert-Identity -Identity $ACL.Owner -Verbose:$false
$IdentityOwnerAdvanced = Get-WinADObject -Identity $ACL.Owner -Cache -Verbose:$false
#} else {
# $IdentityOwner = [PSCustomObject] @{ SID = ''; Type = 'Unknown' }
# $IdentityOwnerAdvanced = [PSCustomObject] @{ ObjectClass = '' }
#}
if (-not $OwnerOnly) {
if (-not $SkipOwner) {
if ($IdentityOwner.SID -eq "S-1-5-32-544") {
$Status = 'OK'
} else {
$Status = 'Replace Owner Required'
$Status = 'Replace owner required'
}
[PSCustomObject] @{
FullName = $File.FullName
Status = $Status
Extension = $File.Extension
CreationTime = $File.CreationTime
LastAccessTime = $File.LastAccessTime
LastWriteTime = $File.LastWriteTime
Attributes = $File.Attributes
AccessControlType = 'Allow' # : Allow
Principal = $IdentityOwner.Name # : BUILTIN\Administrators
PrincipalSid = $IdentityOwner.SID
PrincipalType = $IdentityOwner.Type
FileSystemRights = 'Owner' # : FullControl
IsInherited = $false
FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol)
FullName = $File.FullName
Status = $Status
DomainName = $Domain
Extension = $File.Extension
CreationTime = $File.CreationTime
LastAccessTime = $File.LastAccessTime
LastWriteTime = $File.LastWriteTime
Attributes = $File.Attributes
AccessControlType = 'Allow' # : Allow
Principal = $IdentityOwner.Name # : BUILTIN\Administrators
PrincipalSid = $IdentityOwner.SID
PrincipalType = $IdentityOwner.Type
PrincipalObjectClass = $IdentityOwnerAdvanced.ObjectClass
FileSystemRights = 'Owner' # : FullControl
IsInherited = $false
FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol)
}
}
$FilePermission = Get-FilePermissions -Path $File.FullName -ACLS $ACL -Verbose:$false
foreach ($Perm in $FilePermission) {
$Identity = Convert-Identity -Identity $Perm.Principal -Verbose:$false
$Status = $null
$AdvancedIdentity = Get-WinADObject -Identity $Perm.Principal -Cache -Verbose:$false
$Status = 'Not assesed'
if ($Perm.FileSystemRights -eq [System.Security.AccessControl.FileSystemRights]::FullControl) {
if ($Identity.Type -eq 'WellKnownAdministrative') {
$Status = 'OK'
} else {
$Status = 'Review Required'
if ($AdvancedIdentity.ObjectClass -in 'user', 'computer') {
$Status = 'Removal permission required'
} else {
$Status = 'Review permission required'
}
}
} elseif ($Perm.FileSystemRights -like "*Modify*") {
if ($AdvancedIdentity.ObjectClass -in 'user', 'computer') {
$Status = 'Removal permission required'
} else {
$Status = 'Review permission required'
}
} elseif ($Perm.FileSystemRights -like "*Write*") {
if ($AdvancedIdentity.ObjectClass -in 'user', 'computer') {
$Status = 'Removal permission required'
} else {
$Status = 'Review permission required'
}
}
if ($Identity.Type -eq 'Unknown') {
$Status = 'Removal Required'
$Status = 'Removal permission required'
}
[PSCustomObject] @{
FullName = $File.FullName
Status = $Status
Extension = $File.Extension
CreationTime = $File.CreationTime
LastAccessTime = $File.LastAccessTime
LastWriteTime = $File.LastWriteTime
Attributes = $File.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 = $File.FullName.Replace($Path, $PathOnSysvol)
FullName = $File.FullName
Status = $Status
DomainName = $Domain
Extension = $File.Extension
CreationTime = $File.CreationTime
LastAccessTime = $File.LastAccessTime
LastWriteTime = $File.LastWriteTime
Attributes = $File.Attributes
AccessControlType = $Perm.AccessControlType # : Allow
Principal = $Identity.Name # : BUILTIN\Administrators
PrincipalSid = $Identity.SID
PrincipalType = $Identity.Type
PrincipalObjectClass = $AdvancedIdentity.ObjectClass
FileSystemRights = $Perm.FileSystemRights # : FullControl
IsInherited = $Perm.IsInherited # : True
FullNameOnSysVol = $File.FullName.Replace($Path, $PathOnSysvol)
}
}
} else {
if ($IdentityOwner.SID -eq "S-1-5-32-544") {
$Status = 'OK'
} else {
$Status = 'Replace owner required'
}
[PSCustomObject] @{
FullName = $File.FullName
Status = $Status
DomainName = $Domain
Extension = $File.Extension
CreationTime = $File.CreationTime
LastAccessTime = $File.LastAccessTime
+12 -2
View File
@@ -5,7 +5,11 @@
[string] $FilePath,
[string[]] $Type,
[switch] $PassThru,
[switch] $HideHTML
[switch] $HideHTML,
[alias('ForestName')][string] $Forest,
[string[]] $ExcludeDomains,
[alias('Domain', 'Domains')][string[]] $IncludeDomains
)
Reset-GPOZaurrStatus # This makes sure types are at it's proper status
@@ -30,6 +34,12 @@
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
}
$DisplayForest = if ($Forest) { $Forest } else { 'Not defined. Using current one' }
$DisplayIncludedDomains = if ($IncludeDomains) { $IncludeDomains -join "," } else { 'Not defined. Using all domains of forest' }
$DisplayExcludedDomains = if ($ExcludeDomains) { $ExcludeDomains -join ',' } else { 'No exclusions provided' }
Write-Color '[i]', "[GPOZaurr] ", 'Domain Information', ' [Informative] ', "Forest: ", $DisplayForest -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
Write-Color '[i]', "[GPOZaurr] ", 'Domain Information', ' [Informative] ', "Included Domains: ", $DisplayIncludedDomains -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
Write-Color '[i]', "[GPOZaurr] ", 'Domain Information', ' [Informative] ', "Excluded Domains: ", $DisplayExcludedDomains -Color Yellow, DarkGray, Yellow, DarkGray, Yellow, Magenta
# Lets make sure we only enable those types which are requestd by user
if ($Type) {
@@ -56,7 +66,7 @@
}
$TimeLogGPOList = Start-TimeLog
Write-Color -Text '[i]', '[Start] ', $($Script:GPOConfiguration[$T]['Name']) -Color Yellow, DarkGray, Yellow
$Script:Reporting[$T]['Data'] = Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Execute'] -WarningVariable CommandWarnings -ErrorVariable CommandErrors
$Script:Reporting[$T]['Data'] = Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Execute'] -WarningVariable CommandWarnings -ErrorVariable CommandErrors -ArgumentList $Forest, $ExcludeDomains, $IncludeDomains
Invoke-Command -ScriptBlock $Script:GPOConfiguration[$T]['Processing']
$Script:Reporting[$T]['WarningsAndErrors'] = @(
foreach ($War in $CommandWarnings) {
+16 -15
View File
@@ -33,42 +33,43 @@
}
}
} | Select-Object | Select-Object -First $LimitProcessing | ForEach-Object {
if ($_.Status -eq 'Not available in AD') {
Write-Verbose "Remove-GPOZaurrBroken - Processing $($_.Path)"
$GPO = $_
if ($GPO.Status -eq 'Not available in AD') {
Write-Verbose "Remove-GPOZaurrBroken - Processing $($GPO.Path)"
if ($BackupFinalPath) {
Try {
Write-Verbose "Remove-GPOZaurrBroken - Backing up $($_.Path)"
Copy-Item -LiteralPath $_.Path -Recurse -Destination $BackupFinalPath -ErrorAction Stop
Write-Verbose "Remove-GPOZaurrBroken - Backing up $($GPO.Path)"
Copy-Item -LiteralPath $GPO.Path -Recurse -Destination $BackupFinalPath -ErrorAction Stop
$BackupWorked = $true
} catch {
Write-Warning "Remove-GPOZaurrBroken - Error backing up error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Error backing up $($GPO.Path) error: $($_.Exception.Message)"
$BackupWorked = $false
}
}
if ($BackupWorked -or $BackupFinalPath -eq '') {
Write-Verbose "Remove-GPOZaurrBroken - Deleting $($_.Path)"
Write-Verbose "Remove-GPOZaurrBroken - Deleting $($GPO.Path)"
try {
Remove-Item -Recurse -Force -LiteralPath $_.Path
Remove-Item -Recurse -Force -LiteralPath $GPO.Path -ErrorAction Stop
} catch {
Write-Warning "Remove-GPOZaurrBroken - Failed to remove file $($_.Path): $($_.Exception.Message)."
Write-Warning "Remove-GPOZaurrBroken - Failed to remove file $($GPO.Path): $($_.Exception.Message)."
}
}
} elseif ($_.Status -eq 'Not available on SYSVOL') {
} elseif ($GPO.Status -eq 'Not available on SYSVOL') {
try {
$ExistingObject = Get-ADObject -Identity $_.DistinguishedName -Server $_.DomainName -ErrorAction Stop
$ExistingObject = Get-ADObject -Identity $GPO.DistinguishedName -Server $GPO.DomainName -ErrorAction Stop
} catch {
Write-Warning "Remove-GPOZaurrBroken - Error getting $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Error getting $($GPO.DistinguishedName) from AD error: $($_.Exception.Message)"
$ExistingObject = $null
}
if ($ExistingObject -and $ExistingObject.ObjectClass -eq 'groupPolicyContainer') {
Write-Verbose "Remove-GPOZaurrBroken - Removing DN: $($_.DistinguishedName) / ObjectClass: $($ExistingObject.ObjectClass)"
Write-Verbose "Remove-GPOZaurrBroken - Removing DN: $($GPO.DistinguishedName) / ObjectClass: $($ExistingObject.ObjectClass)"
try {
Remove-ADObject -Server $_.DomainName -Identity $_.DistinguishedName -Recursive -Confirm:$false
Remove-ADObject -Server $GPO.DomainName -Identity $GPO.DistinguishedName -Recursive -Confirm:$false -ErrorAction Stop
} catch {
Write-Warning "Remove-GPOZaurrBroken - Failed to remove $($_.DistinguishedName) from AD error: $($_.Exception.Message)"
Write-Warning "Remove-GPOZaurrBroken - Failed to remove $($GPO.DistinguishedName) from AD error: $($_.Exception.Message)"
}
} else {
Write-Warning "Remove-GPOZaurrBroken - DistinguishedName $($_.DistinguishedName) not found or ObjectClass is not groupPolicyContainer ($($ExistingObject.ObjectClass))"
Write-Warning "Remove-GPOZaurrBroken - DistinguishedName $($GPO.DistinguishedName) not found or ObjectClass is not groupPolicyContainer ($($ExistingObject.ObjectClass))"
}
}
}
+10
View File
@@ -57,6 +57,16 @@ That's it. Whenever there's a new version, you run the command, and you can enjo
## Changelog
- 0.0.86 - 18.11.2020
- [x] Improve error handling `Remove-GPOZaurrBroken`
- 0.0.85 - 17.11.2020
- [x] Improves `Invoke-GPOZaurr` (WIP)
- [x] Split `NetLogonPermissions` into `NetLogonPermissions` and `NetLogonOwners`
- [x] Improved type `NetLogonPermissions`
- [x] Improved type `NetLogonOwners`
- [x] Improves `Get-GPOZaurrFiles`
- [x] Improves `Get-GPOZaurrNetLogon`
- [x] Fix for `Get-GPOZaurrNetLogon`
- 0.0.84 - 16.11.2020
- [x] Improves `Invoke-GPOZaurr` (WIP)
- [x] Type `NetLogonPermissions`