Compare commits

...

13 Commits

Author SHA1 Message Date
Przemyslaw Klys 5d69cef128 changelog update 2021-05-26 22:53:30 +02:00
Przemyslaw Klys 062374b4be Update readme, PSD1 2021-05-26 22:53:10 +02:00
Przemyslaw Klys e61329ac66 Improved certificates 2021-05-26 16:32:07 +02:00
Przemyslaw Klys d3328dbb81 Readme update 2021-05-17 23:22:11 +02:00
Przemyslaw Klys 5803371b5e Update PSD1 2021-05-17 23:14:37 +02:00
Przemyslaw Klys 263f364ede PSM1 update 2021-05-17 23:14:30 +02:00
Przemyslaw Klys 16a181155b Potentially fixes #17 2021-05-17 23:14:16 +02:00
Przemyslaw Klys 962d8829d7 PSD1 update 2021-04-15 18:44:15 +02:00
Przemyslaw Klys 4155c35cc6 Moved description a bit 2021-04-15 18:43:47 +02:00
Przemyslaw Klys 614d8cbda5 PSD1/Readme release 2021-04-12 08:46:35 +02:00
Przemyslaw Klys 43e7f2e746 Dont auto replace words 🐛 2021-04-12 08:45:35 +02:00
Przemyslaw Klys 9a3ed3b6ce Added hidding column 2021-04-12 00:09:47 +02:00
Przemyslaw Klys 50f0cfc1a6 Improved blocked inheritance 2021-04-11 21:36:40 +02:00
8 changed files with 178 additions and 22 deletions
+3 -3
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-GPOZaurrBrokenLink', '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-GPOZaurrPermissionAnalysis', '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-GPOZaurrBrokenLink', 'Repair-GPOZaurrNetLogonOwner', 'Repair-GPOZaurrPermission', 'Repair-GPOZaurrPermissionConsistency', 'Restore-GPOZaurr', 'Save-GPOZaurrFiles', 'Set-GPOOwner', 'Set-GPOZaurrOwner', 'Set-GPOZaurrStatus', 'Skip-GroupPolicy')
GUID = 'f7d4c9e4-0298-4f51-ad77-e8e3febebbde'
ModuleVersion = '0.0.125'
ModuleVersion = '0.0.128'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
@@ -18,11 +18,11 @@
}
}
RequiredModules = @(@{
ModuleVersion = '0.0.198'
ModuleVersion = '0.0.201'
ModuleName = 'PSSharedGoods'
Guid = 'ee272aa8-baaa-4edf-9f45-b6d6f7d844fe'
}, @{
ModuleVersion = '0.0.124'
ModuleVersion = '0.0.128'
ModuleName = 'ADEssentials'
Guid = '9fc9fd61-7f11-4f4b-a527-084086f1905f'
}, @{
+46 -6
View File
@@ -2,13 +2,53 @@
$Public = @( Get-ChildItem -Path $PSScriptRoot\Public\*.ps1 -ErrorAction SilentlyContinue -Recurse )
$Private = @( Get-ChildItem -Path $PSScriptRoot\Private\*.ps1 -ErrorAction SilentlyContinue -Recurse )
#Dot source the files
Foreach ($import in @($Public + $Private)) {
Try {
. $import.fullname
} Catch {
Write-Error -Message "Failed to import function $($import.fullname): $_"
$AssemblyFolders = Get-ChildItem -Path $PSScriptRoot\Lib -Directory -ErrorAction SilentlyContinue
if ($AssemblyFolders.BaseName -contains 'Standard') {
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Standard\*.dll -ErrorAction SilentlyContinue )
} else {
if ($PSEdition -eq 'Core') {
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Core\*.dll -ErrorAction SilentlyContinue )
} else {
$Assembly = @( Get-ChildItem -Path $PSScriptRoot\Lib\Default\*.dll -ErrorAction SilentlyContinue )
}
}
$FoundErrors = @(
Foreach ($Import in @($Assembly)) {
try {
Add-Type -Path $Import.Fullname -ErrorAction Stop
} catch [System.Reflection.ReflectionTypeLoadException] {
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
foreach ($E in $LoaderExceptions) {
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
}
$true
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
} catch {
Write-Warning "Processing $($Import.Name) Exception: $($_.Exception.Message)"
$LoaderExceptions = $($_.Exception.LoaderExceptions) | Sort-Object -Unique
foreach ($E in $LoaderExceptions) {
Write-Warning "Processing $($Import.Name) LoaderExceptions: $($E.Message)"
}
$true
#Write-Error -Message "StackTrace: $($_.Exception.StackTrace)"
}
}
#Dot source the files
Foreach ($Import in @($Private + $Public)) {
Try {
. $Import.Fullname
} Catch {
Write-Error -Message "Failed to import functions from $($import.Fullname): $_"
$true
}
}
)
if ($FoundErrors.Count -gt 0) {
$ModuleName = (Get-ChildItem $PSScriptRoot\*.psd1).BaseName
Write-Warning "Importing module $ModuleName failed. Fix errors before continuing."
break
}
Export-ModuleMember -Function '*' -Alias '*'
+101
View File
@@ -0,0 +1,101 @@
function ConvertTo-XMLCertificates {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[string[]] $Category,
[switch] $SingleObject
)
$SkipNames = ('Name', 'LocalName', 'NamespaceURI', 'Prefix', 'NodeType', 'ParentNode', 'OwnerDocument', 'IsEmpty', 'Attributes', 'HasAttributes', 'SchemaInfo', 'InnerXml', 'InnerText', 'NextSibling', 'PreviousSibling', 'ChildNodes', 'FirstChild', 'LastChild', 'HasChildNodes', 'IsReadOnly', 'OuterXml', 'BaseURI', 'PreviousText')
if ($SingleObject) {
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
Count = 0
Settings = $null
}
[Array] $CreateGPO['Settings'] = foreach ($Setting in $GPO.DataSet) {
$SettingName = $Setting.Name -split ":"
$MySettings = [ordered] @{
CreatedTime = $GPO.CreatedTime # : 06.06.2020 18:03:36
ModifiedTime = $GPO.ModifiedTime # : 17.06.2020 16:08:10
ReadTime = $GPO.ReadTime # : 13.08.2020 10:15:37
SecurityDescriptor = $GPO.SecurityDescriptor # : SecurityDescriptor
FilterDataAvailable = $GPO.FilterDataAvailable # : True
}
$Name = $SettingName[1]
#$Name = Format-ToTitleCase -Text $Setting.Name -RemoveWhiteSpace -RemoveChar ',', '-', "'", '\(', '\)', ':'
$MySettings['Name'] = $Name # $Setting.Name
ConvertTo-XMLNested -CreateGPO $MySettings -Setting $Setting -SkipNames $SkipNames #-Name $Name
if ($MySettings.Data) {
$bytes = $MySettings.Data -replace '\r?\n' -split '(?<=\G.{2})' -ne '' -replace '^', '0x' -as [byte[]]
$CertificateData = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($bytes)
$MySettings['NotBefore'] = $CertificateData.NotBefore
$MySettings['NotAfter'] = $CertificateData.NotAfter
$MySettings['HasPrivateKey'] = $CertificateData.HasPrivateKey
$MySettings['Thumbprint'] = $CertificateData.Thumbprint
$MySettings['SerialNumber'] = $CertificateData.SerialNumber
$MySettings['Version'] = $CertificateData.Version
$MySettings['Handle'] = $CertificateData.Handle
$MySettings['SignatureAlgorithm'] = $CertificateData.SignatureAlgorithm.Value
$MySettings['SignatureAlgorithmName'] = $CertificateData.SignatureAlgorithm.FriendlyName
$MySettings['KeyUsages'] = $CertificateData.Extensions.KeyUsages
$MySettings.Remove('Data')
}
[PSCustomObject] $MySettings
}
$CreateGPO['Count'] = $CreateGPO['Settings'].Count
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
} else {
foreach ($Setting in $GPO.DataSet) {
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
}
$SettingName = $Setting.Name -split ":"
$CreateGPO['CreatedTime'] = $GPO.CreatedTime # : 06.06.2020 18:03:36
$CreateGPO['ModifiedTime'] = $GPO.ModifiedTime # : 17.06.2020 16:08:10
$CreateGPO['ReadTime'] = $GPO.ReadTime # : 13.08.2020 10:15:37
$CreateGPO['SecurityDescriptor'] = $GPO.SecurityDescriptor # : SecurityDescriptor
$CreateGPO['FilterDataAvailable'] = $GPO.FilterDataAvailable # : True
$Name = $SettingName[1]
$CreateGPO['Name'] = $Name # $Setting.Name
ConvertTo-XMLNested -CreateGPO $CreateGPO -Setting $Setting -SkipNames $SkipNames #-Name $Name
if ($CreateGPO.Data) {
$bytes = $CreateGPO.Data -replace '\r?\n' -split '(?<=\G.{2})' -ne '' -replace '^', '0x' -as [byte[]]
$CertificateData = [System.Security.Cryptography.X509Certificates.X509Certificate2]::new($bytes)
$CreateGPO['NotBefore'] = $CertificateData.NotBefore
$CreateGPO['NotAfter'] = $CertificateData.NotAfter
$CreateGPO['HasPrivateKey'] = $CertificateData.HasPrivateKey
$CreateGPO['Thumbprint'] = $CertificateData.Thumbprint
$CreateGPO['SerialNumber'] = $CertificateData.SerialNumber
$CreateGPO['Version'] = $CertificateData.Version
$CreateGPO['Handle'] = $CertificateData.Handle
$CreateGPO['SignatureAlgorithm'] = $CertificateData.SignatureAlgorithm.Value
$CreateGPO['SignatureAlgorithmName'] = $CertificateData.SignatureAlgorithm.FriendlyName
$CreateGPO['KeyUsages'] = $CertificateData.Extensions.KeyUsages
$CreateGPO.Remove('Data')
}
$CreateGPO['Filters'] = $Setting.Filters
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
}
}
}
+1 -1
View File
@@ -290,6 +290,7 @@
'Problem' = $Problem
'ApplyPermission' = $null
'Exclude' = $Exclude
'Description' = $GPO.Description
'ComputerPolicies' = $XMLContent.GPO.Computer.ExtensionData.Name -join ", "
'UserPolicies' = $XMLContent.GPO.User.ExtensionData.Name -join ", "
'LinksCount' = $LinksTotalCount
@@ -315,7 +316,6 @@
'UserSettingsVersionIdentical' = if ($XMLContent.GPO.User.VersionDirectory -eq $XMLContent.GPO.User.VersionSysvol) { $true } else { $false }
'UserSettings' = $XMLContent.GPO.User.ExtensionData.Extension
'NoSettings' = $NoSettings
'Description' = $GPO.Description
'CreationTime' = [DateTime] $XMLContent.GPO.CreatedTime
'ModificationTime' = [DateTime] $XMLContent.GPO.ModifiedTime
'ReadTime' = [DateTime] $XMLContent.GPO.ReadTime
+10 -9
View File
@@ -75,7 +75,7 @@
"By default, Default Domain Policy is linked to the domain and is inherited to all the child objects of the domain hierarchy. "
"So does any other policies linked to the top level OU's. "
}
New-HTMLText -Text "Block Inheritance" -FontSize 10pt -FontWeight bold
New-HTMLText -Text "Blocked Inheritance" -FontSize 10pt -FontWeight bold
New-HTMLText -FontSize 10pt -Text @(
"As GPOs can be inherited by default, they can also be blocked, if required using the Block Inheritance. "
"If the Block Inheritance setting is enabled, the inheritance of group policy setting is blocked. "
@@ -85,10 +85,10 @@
New-HTMLText -Text @(
'As it stands currently there are ',
$Script:Reporting['GPOBlockedInheritance']['Data'].Count,
' organiational units with '
' organisational units with '
'GPO Inheritance Block'
' out of which '
$Script:Reporting['GPOBlockedInheritance']['Variables']['Exclude'].Count,
$Script:Reporting['GPOBlockedInheritance']['Variables']['Exclude'],
' are marked as Excluded '
'(approved by IT). '
) -FontSize 10pt -FontWeight normal, bold, normal, bold, normal, bold, normal, bold -LineBreak
@@ -96,9 +96,9 @@
New-HTMLText -Text 'Users & Computers affected by inheritance blocks:' -FontSize 10pt -FontWeight bold
New-HTMLList -Type Unordered {
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['UsersAffected'], ' users affected due to inheritance blocks' -FontWeight bold, normal
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['UsersAffectedExclude'], ' users affected, but approved/Exclude, due to inheritance blocks' -FontWeight bold, normal
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['UsersAffectedExclude'], ' users affected, but approved/excluded, due to inheritance blocks' -FontWeight bold, normal
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['ComputersAffected'], ' computers affected due to inheritance blocks' -FontWeight bold, normal
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['ComputersAffectedExclude'], ' computers affected, but approved/Exclude, due to inheritance blocks' -FontWeight bold, normal
New-HTMLListItem -Text $Script:Reporting['GPOBlockedInheritance']['Variables']['ComputersAffectedExclude'], ' computers affected, but approved/excluded, due to inheritance blocks' -FontWeight bold, normal
} -FontSize 10pt
New-HTMLText -Text 'Following domains require:' -FontSize 10pt -FontWeight bold
@@ -118,7 +118,7 @@
}
New-HTMLPanel {
New-HTMLChart {
New-ChartLegend -Names 'Affected', 'Affected, but Exclude' -Color Salmon, PaleGreen
New-ChartLegend -Names 'Affected', 'Affected, but excluded' -Color Salmon, PaleGreen
New-ChartBarOptions -Type barStacked
New-ChartBar -Name 'Users' -Value $Script:Reporting['GPOBlockedInheritance']['Variables']['UsersAffected'], $Script:Reporting['GPOBlockedInheritance']['Variables']['UsersAffectedExclude']
New-ChartBar -Name 'Computers' -Value $Script:Reporting['GPOBlockedInheritance']['Variables']['ComputersAffected'], $Script:Reporting['GPOBlockedInheritance']['Variables']['ComputersAffectedExclude']
@@ -137,14 +137,15 @@
New-TableCondition -Name 'UsersCount' -Value 0
New-TableCondition -Name 'ComputersCount' -Value 0
} -BackgroundColor Salmon -FailBackgroundColor Amber -HighlightHeaders 'UsersCount', 'ComputersCount'
} -PagingOptions 10, 20, 30, 40, 50 -SearchBuilder -ExcludeProperty GroupPolicies
New-TableColumnOption -Hidden $true -ColumnIndex 8
} -PagingOptions 5, 10, 20, 30, 40, 50 -SearchBuilder -ExcludeProperty GroupPolicies
}
New-HTMLSection -Name 'Group Policies affecting objects in Organizational Units with Blocked Inheritance' {
New-HTMLTable -DataTable $Script:Reporting['GPOBlockedInheritance']['Data'].GroupPolicies -Filtering {
New-TableCondition -Name 'Enabled' -Value $true -BackgroundColor SpringGreen -FailBackgroundColor Salmon
New-TableCondition -Name 'Enforced' -Value $true -BackgroundColor Amber -FailBackgroundColor AirForceBlue
New-TableCondition -Name 'LinkedDirectly' -Value $true -BackgroundColor Amber -FailBackgroundColor AirForceBlue
} -PagingOptions 10, 20, 30, 40, 50 -SearchBuilder -ExcludeProperty GroupPolicies -DataTableID 'TableWithGroupPoliciesBlockedInheritance'
} -PagingOptions 5, 10, 20, 30, 40, 50 -SearchBuilder -DataTableID 'TableWithGroupPoliciesBlockedInheritance'
}
if ($Script:Reporting['Settings']['HideSteps'] -eq $false) {
New-HTMLSection -Name 'Steps to fix - Organizational Units with Group Policy Blocked Inheritance' {
@@ -174,7 +175,7 @@
}
New-HTMLText -Text "Alternatively if you prefer working with console you can run: "
New-HTMLCodeBlock -Code {
$GPOOutput = Get-GPOZaurrInheritance -IncludeBlockedObjects -IncludeExcludeObjects -OnlyBlockedInheritance
$GPOOutput = Get-GPOZaurrInheritance -IncludeBlockedObjects -IncludeExcludedObjects -OnlyBlockedInheritance
$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."
+2 -2
View File
@@ -789,10 +789,10 @@
)
GPOPath = 'Policies -> Windows Settings -> Security Settings -> Public Key Policies'
Code = {
ConvertTo-XMLGenericPublicKey -GPO $GPO
ConvertTo-XMLCertificates -GPO $GPO
}
CodeSingle = {
ConvertTo-XMLGenericPublicKey -GPO $GPO -SingleObject
ConvertTo-XMLCertificates -GPO $GPO -SingleObject
}
}
<#
+3 -1
View File
@@ -212,7 +212,9 @@
$DisplayProperties = @(
$FirstProperties
foreach ($Property in $Properties) {
$Property
if ($Property -notin $FirstProperties -and $Property -notin $EndProperties) {
$Property
}
}
$EndProperties
)
+12
View File
@@ -55,6 +55,18 @@ To understand the usage I've created blog post you may find useful
## Changelog
- 0.0.128 - 2021.05.26
- ☑ Improved `Invoke-GPOZaurrContent` - type `PublicKeyPoliciesCertificates` - added more certificate information
- ☑ Improved `Invoke-GPOZaurr` - type `GPOAnalysis` - added more certificate information
- 0.0.128 Alpha 1 - 2021.05.17
- 🐛 Fixes errors when normalizing properties [#17](https://github.com/EvotecIT/GPOZaurr/issues/17)
- 0.0.127 - 2021.04.15
- ☑ Improved `Invoke-GPOZaurr`
- ☑ Report `GPOList` - moved description closer to statuses
- ☑ Improved `Get-GPOZaurr` - moved description closer to statuses
- 0.0.126 - 2021.04.12
- ☑ Improved `Invoke-GPOZaurr`
- ☑ Report `GPOBlockedInheritance` - hidden DistinguishedName, fixed some small typos
- 0.0.125 - 2021.04.11
- ☑ Improved `Invoke-GPOZaurr`
- ☑ Report `GPOBlockedInheritance` - small fixes