Compare commits

...

22 Commits

Author SHA1 Message Date
Przemyslaw Klys 37483c91b5 Update PSD1 2021-02-10 19:51:17 +01:00
Przemyslaw Klys 9172948be3 Added folder redirection #12 2021-02-10 19:50:45 +01:00
Przemyslaw Klys 14567959f7 #12 2021-02-10 19:49:51 +01:00
Przemyslaw Klys 6a9ad14083 Modified readme 2021-02-10 19:25:10 +01:00
Przemyslaw Klys e00de40cd2 Adds description #13 2021-02-10 19:24:04 +01:00
Przemyslaw Klys 6f806698e9 update readme 2021-02-10 12:02:01 +01:00
Przemyslaw Klys 2e1571b0d7 Update 2021-02-10 11:56:31 +01:00
Przemyslaw Klys ffedd2d9d2 Update 2021-02-10 11:56:23 +01:00
Przemyslaw Klys 911bc50f22 Update readme 2021-02-10 11:00:52 +01:00
Przemyslaw Klys 0383d249e9 PSD1 update 2021-02-10 10:57:12 +01:00
Przemyslaw Klys 8070179d27 Update readme 2021-02-10 10:56:48 +01:00
Przemyslaw Klys db67e6191e Improved false-positive detection for Empty on non-english systesm 2021-02-10 10:47:23 +01:00
Przemyslaw Klys db9b6d60c6 PSD1 update 2021-02-09 18:07:24 +01:00
Przemyslaw Klys 2c965d81d5 Small update 2021-02-09 18:01:48 +01:00
Przemyslaw Klys bff372affe Update readme 2021-02-09 17:58:06 +01:00
Przemyslaw Klys 138a0f411e Added information about filepath 2021-02-09 17:56:56 +01:00
Przemyslaw Klys 1c37a9d1df Update readme / PSD1 2021-02-09 10:58:02 +01:00
Przemyslaw Klys 30535c1baf Update readme 2021-02-09 10:55:23 +01:00
Przemyslaw Klys 56c722edd0 Small fix to exclude GPOList.xml 2021-02-09 10:54:43 +01:00
Przemyslaw Klys 1f43ae21fe PSD1 update 2021-02-08 17:43:40 +01:00
Przemyslaw Klys ef90ef05f7 Update readme 2021-02-08 17:43:13 +01:00
Przemyslaw Klys 43b304d252 Removed redundant code
Handles ObjectClass problem properly now
2021-02-08 17:43:07 +01:00
8 changed files with 177 additions and 38 deletions
+1 -1
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.115'
ModuleVersion = '0.0.121'
PowerShellVersion = '5.1'
PrivateData = @{
PSData = @{
@@ -0,0 +1,70 @@
function ConvertTo-XMLFolderRedirection {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[switch] $SingleObject
)
if ($SingleObject) {
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
Count = 0
Settings = $null
}
[Array] $CreateGPO['Settings'] = foreach ($Folder in $GPO.DataSet) {
foreach ($Location in $Folder.Location) {
[PSCustomObject] @{
DestinationPath = $Location.DestinationPath
SecuritySID = $Location.SecurityGroup.SID.'#text'
SecurityName = $Location.SecurityGroup.Name.'#text'
GrantExclusiveRights = if ($Folder.GrantExclusiveRights -eq 'true') { $true } else { $false }
MoveContents = if ($Folder.MoveContents -eq 'true') { $true } else { $false }
FollowParent = if ($Folder.FollowParent -eq 'true') { $true } else { $false }
ApplyToDownLevel = if ($Folder.ApplyToDownLevel -eq 'true') { $true } else { $false }
DoNotCare = if ($Folder.DoNotCare -eq 'true') { $true } else { $false }
RedirectToLocal = if ($Folder.RedirectToLocal -eq 'true') { $true } else { $false }
PolicyRemovalBehavior = $Folder.PolicyRemovalBehavior # : LeaveContents
ConfigurationControl = if ($Folder.ConfigurationControl -eq 'GP') { 'Group Policy' } else { $Folder.ConfigurationControl } # : GP
PrimaryComputerEvaluation = $Folder.PrimaryComputerEvaluation # : PrimaryComputerPolicyDisabled
}
}
}
$CreateGPO['Count'] = $CreateGPO['Settings'].Count
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
} else {
foreach ($Folder in $GPO.DataSet) {
foreach ($Location in $Folder.Location) {
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
Id = $Folder.Id
DestinationPath = $Location.DestinationPath
SecuritySID = $Location.SecurityGroup.SID.'#text'
SecurityName = $Location.SecurityGroup.Name.'#text'
GrantExclusiveRights = if ($Folder.GrantExclusiveRights -eq 'true') { $true } else { $false }
MoveContents = if ($Folder.MoveContents -eq 'true') { $true } else { $false }
FollowParent = if ($Folder.FollowParent -eq 'true') { $true } else { $false }
ApplyToDownLevel = if ($Folder.ApplyToDownLevel -eq 'true') { $true } else { $false }
DoNotCare = if ($Folder.DoNotCare -eq 'true') { $true } else { $false }
RedirectToLocal = if ($Folder.RedirectToLocal -eq 'true') { $true } else { $false }
PolicyRemovalBehavior = $Folder.PolicyRemovalBehavior # : LeaveContents
ConfigurationControl = if ($Folder.ConfigurationControl -eq 'GP') { 'Group Policy' } else { $Folder.ConfigurationControl } # : GP
PrimaryComputerEvaluation = $Folder.PrimaryComputerEvaluation # : PrimaryComputerPolicyDisabled
Linked = $GPO.Linked
LinksCount = $GPO.LinksCount
Links = $GPO.Links
}
[PSCustomObject] $CreateGPO
}
}
}
}
+58 -30
View File
@@ -12,6 +12,10 @@
[string[]] $Type,
[System.Collections.IDictionary] $LinksSummaryCache
)
$DisplayName = $XMLContent.GPO.Name
$DomainName = $XMLContent.GPO.Identifier.Domain.'#text'
if ($LinksSummaryCache) {
$SearchGUID = -join ($XMLContent.GPO.Identifier.Domain.'#text', $XMLContent.GPO.Identifier.Identifier.InnerText -replace '{' -replace '}')
if ($LinksSummaryCache[$SearchGUID]) {
@@ -73,7 +77,7 @@
} elseif ($XMLContent.GPO.Computer.Enabled -eq 'True') {
$ComputerEnabled = $true
} else {
Write-Warning "Get-XMLGPO - Computer enabled not set to true or false. Weird."
Write-Warning "Get-XMLGPO - Computer enabled not set to true or false [$DisplayName/$DomainName]. Weird."
$ComputerEnabled = $null
}
if ($XMLContent.GPO.User.Enabled -eq 'False') {
@@ -81,7 +85,7 @@
} elseif ($XMLContent.GPO.User.Enabled -eq 'True') {
$UserEnabled = $true
} else {
Write-Warning "Get-XMLGPO - User enabled not set to true or false. Weird."
Write-Warning "Get-XMLGPO - User enabled not set to true or false [$DisplayName/$DomainName] . Weird."
$UserEnabled = $null
}
# Translate Enabled to same as GPO GUI
@@ -100,8 +104,8 @@
}
# This is kind of old way of doing things, but it's superseded by other way below
$ComputerSettingsAvailable = if ($null -eq $XMLContent.GPO.Computer.ExtensionData) { $false } else { $true }
$UserSettingsAvailable = if ($null -eq $XMLContent.GPO.User.ExtensionData) { $false } else { $true }
[bool] $ComputerSettingsAvailable = if ($null -eq $XMLContent.GPO.Computer.ExtensionData) { $false } else { $true }
[bool] $UserSettingsAvailable = if ($null -eq $XMLContent.GPO.User.ExtensionData) { $false } else { $true }
if ($ComputerSettingsAvailable -eq $false -and $UserSettingsAvailable -eq $false) {
$NoSettings = $true
@@ -112,35 +116,58 @@
# $OutputUser = $XMLContent.GPO.User.ExtensionData.Extension | Where-Object { $_.PSObject.Properties.TypeNameOfValue -in 'System.Xml.XmlElement', 'System.Object[]' }
# $OutputComputer = $XMLContent.GPO.Computer.ExtensionData.Extension | Where-Object { $_.PSObject.Properties.TypeNameOfValue -in 'System.Xml.XmlElement', 'System.Object[]' }
$OutputUser = foreach ($ExtensionType in $XMLContent.GPO.User.ExtensionData.Extension) {
if ($ExtensionType) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
try {
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties -ErrorAction Stop | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] -and $_.Name -notin @('Blocked') }
} catch {
Write-Warning "Get-XMLGPO - things went sideways $($_.Exception.Message)"
continue
}
# This is additional check we do for error check to prevent false-positives for EMPTY on non-english language
$PreCheckOutputUser = $false
$PreCheckOutputComputer = $false
foreach ($Extension in $XMLContent.GPO.User.ExtensionData) {
if ($Extension.Error) {
$PreCheckOutputUser = $true
}
$KeysToLoop
}
$OutputComputer = foreach ($ExtensionType in $XMLContent.GPO.Computer.ExtensionData.Extension) {
if ($ExtensionType) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
try {
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties -ErrorAction Stop | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] -and $_.Name -notin @('Blocked') }
} catch {
Write-Warning "Get-XMLGPO - things went sideways $($_.Exception.Message)"
continue
}
foreach ($Extension in $XMLContent.GPO.Computer.ExtensionData) {
if ($Extension.Error) {
$PreCheckOutputComputer = $true
}
$KeysToLoop
}
if ($PreCheckOutputComputer -eq $true -or $PreCheckOutputUser -eq $true) {
# in some cases GPResult seems to return an error - this was first noticed by user when using Dutch based system
# I am not sure if it's possible to fix this error for users, but once that happens checking if GPO is empty fails using the method below
# therefore we will use the old method of assuming something is empty or not empty in such case
Write-Warning "Get-XMLGPO - Reading GPO content [$DisplayName/$DomainName] returned an error. This may be because of non-english language. Assesing EMPTY using old method which can report false positives. Be careful please."
$OutputUser = @()
$OutputComputer = @()
} else {
[Array] $OutputUser = foreach ($ExtensionType in $XMLContent.GPO.User.ExtensionData.Extension) {
if ($ExtensionType) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
try {
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties -ErrorAction Stop | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] -and $_.Name -notin @('Blocked') }
} catch {
Write-Warning "Get-XMLGPO - things went sideways [$DisplayName/$DomainName]. Error $($_.Exception.Message)"
continue
}
}
$KeysToLoop
}
[Array] $OutputComputer = foreach ($ExtensionType in $XMLContent.GPO.Computer.ExtensionData.Extension) {
if ($ExtensionType) {
$GPOSettingTypeSplit = ($ExtensionType.type -split ':')
try {
$KeysToLoop = $ExtensionType | Get-Member -MemberType Properties -ErrorAction Stop | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] -and $_.Name -notin @('Blocked') }
} catch {
Write-Warning "Get-XMLGPO - things went sideways [$DisplayName/$DomainName]. Error $($_.Exception.Message)"
continue
}
}
$KeysToLoop
}
[bool] $ComputerSettingsAvailable = if ($OutputComputer.Count -gt 0) { $true } else { $false }
[bool] $UserSettingsAvailable = if ($OutputUser.Count -gt 0) { $true } else { $false }
}
$ComputerSettingsAvailable = if ($OutputComputer) { $true } else { $false }
$UserSettingsAvailable = if ($OutputUser) { $true } else { $false }
if (-not $ComputerSettingsAvailable -and -not $UserSettingsAvailable) {
if ($ComputerSettingsAvailable -eq $false -and $UserSettingsAvailable -eq $false) {
$Empty = $true
} else {
$Empty = $false
@@ -277,8 +304,8 @@
'UserSettingsAvailable' = $UserSettingsAvailable
#'ComputerSettingsAvailableReal' = $ComputerSettingsAvailableReal
#'UserSettingsAvailableReal' = $UserSettingsAvailableReal
'ComputerSettingsTypes' = $OutputComputer.Name
'UserSettingsTypes' = $OutputUser.Name
'ComputerSettingsTypes' = $OutputComputer.Name -join ", "
'UserSettingsTypes' = $OutputUser.Name -join ", "
'ComputerEnabled' = $ComputerEnabled
'UserEnabled' = $UserEnabled
'ComputerSettingsStatus' = if ($XMLContent.GPO.Computer.VersionDirectory -eq 0 -and $XMLContent.GPO.Computer.VersionSysvol -eq 0) { "NeverModified" } else { "Modified" }
@@ -288,6 +315,7 @@
'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
+15
View File
@@ -336,6 +336,21 @@
}
}
FolderRedirection = @{
Types = @(
@{
Category = 'FolderRedirectionSettings'
Settings = 'Folder'
}
)
GPOPath = 'Windows Settings -> Folder Redirection'
Code = {
ConvertTo-XMLFolderRedirection -GPO $GPO
}
CodeSingle = {
ConvertTo-XMLFolderRedirection -GPO $GPO -SingleObject
}
}
FolderRedirectionPolicy = @{
Types = @(
@{
Category = 'RegistrySettings'
+5 -3
View File
@@ -100,9 +100,11 @@
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 -ExcludeGroupPolicies $ExcludeGPO -Type $Type
if ($_.Name -ne 'GPOList.xml') {
$XMLContent = [XML]::new()
$XMLContent.Load($_.FullName)
Get-XMLGPO -OwnerOnly:$OwnerOnly.IsPresent -XMLContent $XMLContent -PermissionsOnly:$PermissionsOnly.IsPresent -ExcludeGroupPolicies $ExcludeGPO -Type $Type
}
}
Write-Verbose "Get-GPOZaurr - Finished GPO content from XML files"
}
+4 -1
View File
@@ -144,7 +144,10 @@
# Generate pretty HTML
$TimeLogHTML = Start-TimeLog
Write-Color -Text '[i]', '[HTML ] ', 'Generating HTML report' -Color Yellow, DarkGray, Yellow
if (-not $FilePath) {
$FilePath = Get-FileName -Extension 'html' -Temporary
}
Write-Color -Text '[i]', '[HTML ] ', "Generating HTML report ($FilePath)" -Color Yellow, DarkGray, Yellow
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
+5 -3
View File
@@ -108,21 +108,23 @@
}
if ($GPO.Status -in 'Not available on SYSVOL', 'ObjectClass issue') {
Write-Verbose "Remove-GPOZaurrBroken - Removing from AD [$($GPO.Status)] $($GPO.DistinguishedName)"
<#
try {
$ExistingObject = Get-ADObject -Identity $GPO.DistinguishedName -Server $GPO.DomainName -ErrorAction Stop
} catch {
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: $($GPO.DistinguishedName) / ObjectClass: $($ExistingObject.ObjectClass)"
#>
if ($GPO -and $GPO.ObjectClass -in 'groupPolicyContainer', 'Container') {
Write-Verbose "Remove-GPOZaurrBroken - Removing DN: $($GPO.DistinguishedName) / ObjectClass: $($GPO.ObjectClass)"
try {
Remove-ADObject -Server $GPO.DomainName -Identity $GPO.DistinguishedName -Recursive -Confirm:$false -ErrorAction Stop
} catch {
Write-Warning "Remove-GPOZaurrBroken - Failed to remove $($GPO.DistinguishedName) from AD error: $($_.Exception.Message)"
}
} else {
Write-Warning "Remove-GPOZaurrBroken - DistinguishedName $($GPO.DistinguishedName) not found or ObjectClass is not groupPolicyContainer ($($ExistingObject.ObjectClass))"
Write-Warning "Remove-GPOZaurrBroken - DistinguishedName $($GPO.DistinguishedName) not found or ObjectClass is not groupPolicyContainer/Container ($($GPO.ObjectClass))"
}
}
}
+19
View File
@@ -64,6 +64,25 @@ To understand the usage I've created blog post you may find useful
## Changelog
- 0.0.121 - 2021.02.10
- [x] Improvement to `Get-GPOZaurr` - added description [#13](https://github.com/EvotecIT/GPOZaurr/issues/13)
- [x] Improvement to `Invoke-GPOZaurr -Type GPOList` - added description [#13](https://github.com/EvotecIT/GPOZaurr/issues/13)
- [x] Improved `Invoke-GPOZaurr`
- [x] Report GPOAnalysis - added `FolderRedirection`
- [x] Report GPOAnalysis - renamed `FolderRedirection` to `FolderRedirectionPolicy`
- [x] Improved `Invoke-GPOZaurrContent` as mentioned above for `GPOAnalysis`
- 0.0.120 - 2021.02.10
- [x] Improvement to `Get-GPOZaurr` to warn if there is potential issue with EMPTY (which can happen on non-english system)
- [x] In such case GPOZaurr will asses EMPTY or not using old method which doesn't detect all EMPTY cases but shouldn't provide false positives
- 0.0.119
- Broken release - weird
- 0.0.118 - 2021.02.09
- [x] Added information where the report is saved
- [x] Small improvement to `Get-GPOZaurr` to exlicitly define variable types
- 0.0.117 - 2021.02.09
- [x] Small fix to `Get-GPOZaurr` to exclude GPOList.xml which is used in offline mode by `Save-GPOZaurrFiles`
- 0.0.116 - 2021.02.08
- [x] Improved `Remove-GPOZaurrBroken` to handle ObjectClass problem, and removed reduntant check
- 0.0.115 - 2021.02.07
- [x] Improved `Invoke-GPOZaurr`
- [x] `GPOList` - clarified some texts, changed 7 days to 30 days as default