From 7cff95cc811dd7d0427602860d997905104de761 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Sat, 27 Jun 2020 18:19:45 +0200 Subject: [PATCH] Updates to Find-GPO --- Examples/Example-29-FindGPOfromDisk.ps1 | 17 ++++++++++++----- Private/Get-XMLStandard.ps1 | 17 +++++++++-------- Public/Find-GPO.ps1 | 25 +++++++++++++++++++++---- 3 files changed, 42 insertions(+), 17 deletions(-) diff --git a/Examples/Example-29-FindGPOfromDisk.ps1 b/Examples/Example-29-FindGPOfromDisk.ps1 index d531536..f484f6b 100644 --- a/Examples/Example-29-FindGPOfromDisk.ps1 +++ b/Examples/Example-29-FindGPOfromDisk.ps1 @@ -3,12 +3,19 @@ # Use Save-GPOZaurrFiles -GPOPath $ENV:USERPROFILE\Desktop\GPOExport $Output = Find-GPO -GPOPath 'C:\Support\GitHub\GpoZaurr\Ignore\GPOExportTest' -$Output | Format-Table * +$Output | Format-Table New-HTML { - foreach ($Key in $Output.Keys) { - New-HTMLTab -Name $Key { - New-HTMLTable -DataTable $Output[$Key] -ScrollX -DisablePaging -AllProperties -Title $Key + foreach ($GPOCategory in $Output.Keys) { + New-HTMLTab -Name $GPOCategory { + foreach ($GpoSettings in $Output.$GPOCategory.Keys) { + New-HTMLTab -Name $GpoSettings { + New-HTMLTable -DataTable $Output[$GPOCategory][$GpoSettings] -ScrollX -DisablePaging -AllProperties -Title $Key + } + } } } -} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO.html \ No newline at end of file +} -Online -ShowHTML -FilePath $Env:UserProfile\Desktop\OutputFromFindGPO.html + + +#Select-Properties -AllProperties -Objects $Output.SecuritySettings \ No newline at end of file diff --git a/Private/Get-XMLStandard.ps1 b/Private/Get-XMLStandard.ps1 index c69e5fa..8c5e45d 100644 --- a/Private/Get-XMLStandard.ps1 +++ b/Private/Get-XMLStandard.ps1 @@ -3,17 +3,17 @@ param( [PSCustomObject] $GPO, [System.Xml.XmlElement[]] $GPOOutput, - [string] $Splitter = [System.Environment]::NewLine, + [string] $Splitter, [switch] $FullObjects ) $LinksInformation = Get-LinksFromXML -GPOOutput $GPOOutput -Splitter $Splitter -FullObjects:$FullObjects - foreach ($Type in @('User', 'Computer')) { - if ($GPOOutput.$Type.ExtensionData.Extension) { - foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) { + foreach ($GpoType in @('User', 'Computer')) { + if ($GPOOutput.$GpoType.ExtensionData.Extension) { + foreach ($ExtensionType in $GPOOutput.$GpoType.ExtensionData.Extension) { $GPOSettingTypeSplit = ($ExtensionType.type -split ':') $KeysToLoop = $ExtensionType | Get-Member -MemberType Properties | Where-Object { $_.Name -notin 'type', $GPOSettingTypeSplit[0] } - foreach ($Keys in $KeysToLoop.Name) { - foreach ($Key in $ExtensionType.$Keys) { + foreach ($GpoSettings in $KeysToLoop.Name) { + foreach ($Key in $ExtensionType.$GpoSettings) { $Template = [ordered] @{ DisplayName = $GPO.DisplayName DomainName = $GPO.DomainName @@ -21,8 +21,9 @@ Linked = $LinksInformation.Linked LinksCount = $LinksInformation.LinksCount Links = $LinksInformation.Links - GpoType = $Type - GpoSubType = $GPOSettingTypeSplit[1] + GpoType = $GpoType + GpoCategory = $GPOSettingTypeSplit[1] + GpoSettings = $GpoSettings } $Properties = ($Key | Get-Member -MemberType Properties).Name foreach ($Property in $Properties) { diff --git a/Public/Find-GPO.ps1 b/Public/Find-GPO.ps1 index 49ccb6c..0dcd9d7 100644 --- a/Public/Find-GPO.ps1 +++ b/Public/Find-GPO.ps1 @@ -77,16 +77,32 @@ UserPolicies = $GPOOutput.GPO.User.ExtensionData.Name -join ", " } #> - $GPOStoredTypes = Get-XMLGPOTypes -GPOOutput $GPOOutput.GPO + + $GPODitionary = @{ + 'SecuritySettings' = @{ + Name = 'Security Settings' + Translate = [ordered] @{ + + } + } + } + + + + #$GPOStoredTypes = Get-XMLGPOTypes -GPOOutput $GPOOutput.GPO [Array] $Data = Get-XMLStandard -GPO $GPO -GPOOutput $GPOOutput.GPO -Splitter $Splitter -FullObjects:$FullObjects foreach ($D in $Data) { - if (-not $Output["$($D.GpoSubType)"]) { - $Output["$($D.GpoSubType)"] = [System.Collections.Generic.List[PSCustomObject]]::new() + if (-not $Output["$($D.GpoCategory)"]) { + $Output["$($D.GpoCategory)"] = [ordered] @{} } - $Output["$($D.GpoSubType)"].Add($D) + if (-not $Output["$($D.GpoCategory)"]["$($D.GpoSettings)"]) { + $Output["$($D.GpoCategory)"]["$($D.GpoSettings)"] = [System.Collections.Generic.List[PSCustomObject]]::new() + } + $Output["$($D.GpoCategory)"]["$($D.GpoSettings)"].Add($D) } + <# continue if ($Type -contains 'RegistrySettings') { @@ -143,6 +159,7 @@ $Output['SystemServices'].Add($D) } } + #> } $Output } \ No newline at end of file