diff --git a/Private/Get-XMLGPOTypes.ps1 b/Private/Get-XMLGPOTypes.ps1 new file mode 100644 index 0000000..ec45c4d --- /dev/null +++ b/Private/Get-XMLGPOTypes.ps1 @@ -0,0 +1,31 @@ +function Get-XMLGPOTypes { + [cmdletBinding()] + param( + [PSCustomObject] $GPO, + [System.Xml.XmlElement[]] $GPOOutput, + [string] $Splitter = [System.Environment]::NewLine, + [switch] $FullObjects + ) + + $Types = [ordered] @{ + User = [System.Collections.Generic.List[string]]::new() + Computer = [System.Collections.Generic.List[string]]::new() + All = $null + } + + [Array] $TypesReturn = foreach ($Type in @('User', 'Computer')) { + if ($GPOOutput.$Type.ExtensionData.Extension) { + foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) { + $GPOSettingType = ($ExtensionType.type -split ':')[1] + # add to hashtable + $Types["$Type"].Add($GPOSettingType) + # add to array + $GPOSettingType + } + } + } + $Types.Computer = $Types.Computer | Sort-Object -Unique + $Types.User = $Types.User | Sort-Object -Unique + $Types.All = $TypesReturn | Sort-Object -Unique + $Types +} \ No newline at end of file diff --git a/Private/Get-XMLStandard.ps1 b/Private/Get-XMLStandard.ps1 index 7086e03..c69e5fa 100644 --- a/Private/Get-XMLStandard.ps1 +++ b/Private/Get-XMLStandard.ps1 @@ -10,34 +10,28 @@ foreach ($Type in @('User', 'Computer')) { if ($GPOOutput.$Type.ExtensionData.Extension) { foreach ($ExtensionType in $GPOOutput.$Type.ExtensionData.Extension) { - $GPOSettingType = ($ExtensionType.type -split ':')[1] - Write-Warning $GPOSettingType - foreach ($Key in $ExtensionType.Account) { - [PSCustomObject] @{ - DisplayName = $GPO.DisplayName - DomainName = $GPO.DomainName - GUID = $GPO.Guid - Linked = $LinksInformation.Linked - LinksCount = $LinksInformation.LinksCount - Links = $LinksInformation.Links - GpoType = $Type - Name = $Key.Name - Type = $Key.Type - SettingNumber = $Key.SettingNumber - SettingBoolean = if ($Key.SettingBoolean -eq 'true') { $true } elseif ($Key.SettingBoolean -eq 'false') { $false } else { $null } + $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) { + $Template = [ordered] @{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.Guid + Linked = $LinksInformation.Linked + LinksCount = $LinksInformation.LinksCount + Links = $LinksInformation.Links + GpoType = $Type + GpoSubType = $GPOSettingTypeSplit[1] + } + $Properties = ($Key | Get-Member -MemberType Properties).Name + foreach ($Property in $Properties) { + $Template["$Property"] = $Key.$Property + } + [PSCustomObject] $Template } } } } } -} - -<# -q1 : http://www.microsoft.com/GroupPolicy/Settings/Security -type : q1:SecuritySettings -Account : {ClearTextPassword, LockoutBadCount, LockoutDuration, MaximumPasswordAge...} -SecurityOptions : SecurityOptions -SystemServices : SystemServices -#> - -#$GPOSettingType = ($ExtensionType.type -split ':')[1] +} \ No newline at end of file diff --git a/Public/Find-GPO.ps1 b/Public/Find-GPO.ps1 index 916f678..49ccb6c 100644 --- a/Public/Find-GPO.ps1 +++ b/Public/Find-GPO.ps1 @@ -57,7 +57,7 @@ } $Output = [ordered] @{} foreach ($T in $Type) { - $Output[$T] = [System.Collections.Generic.List[PSCustomObject]]::new() + # $Output[$T] = [System.Collections.Generic.List[PSCustomObject]]::new() } foreach ($GPO in $GPOs) { if ($GPOPath) { @@ -77,6 +77,18 @@ UserPolicies = $GPOOutput.GPO.User.ExtensionData.Name -join ", " } #> + $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() + } + $Output["$($D.GpoSubType)"].Add($D) + } + + continue + if ($Type -contains 'RegistrySettings') { [Array] $Data = Get-XMLRegistrySettings -GPO $GPO -GPOOutput $GPOOutput.GPO -Splitter $Splitter -FullObjects:$FullObjects foreach ($D in $Data) {