$language = "de-DE" $root = "C:\Windows\PolicyDefinitions" $output = @() $admx_files = Get-ChildItem $root -Filter "*.admx" foreach ($admx in $admx_files) { $admx_file = Split-Path $admx -Leaf $adml = "C:\Windows\PolicyDefinitions\$($language)\$($admx_file.TrimEnd('x'))l" if (Test-Path $adml) { $admx_data = [xml](Get-Content $admx.FullName) $adml_data = [xml](Get-Content $adml -Encoding UTF8) $adml_strings = $adml_data.policyDefinitionResources.resources.stringTable.GetEnumerator() $policies = $admx_data.policyDefinitions.policies foreach ($pol in $policies.policy) { $dn_string = $pol.displayName.Substring(9, ($pol.displayName.Length - 10)) $et_string = $pol.explainText.Substring(9, ($pol.explainText.Length - 10)) $policy_name = ($adml_strings.Where({$_.id -eq $dn_string})).'#text' $adml_strings.Reset() $policy_desc = ($adml_strings.Where({$_.id -eq $et_string})).'#text' $adml_strings.Reset() if ($pol.elements.HasChildNodes) { $els = $pol.elements.GetEnumerator() foreach ($el in $els) { $reg_value = "$($pol.Key)\$($el.valueName)" $reg_type = "" switch ($el.Name) { 'boolean' { $reg_type = 'REG_DWORD (1)' } 'decimal' { $reg_type = 'REG_DWORD' } 'text' { if ($el.expandable) { $reg_type = 'REG_EXPAND_SZ' } else { $reg_type = 'REG_SZ' } } 'enum' { $ex = $el.FirstChild.FirstChild.FirstChild.Name switch ($ex) { 'decimal' { $reg_type = 'REG_DWORD' } 'text' { if ($el.expandable) { $reg_type = 'REG_EXPAND_SZ' } else { $reg_type = 'REG_SZ' } } } } 'list' { $reg_type = 'REG_SZ (list)' $reg_value = $el.Key } default { Write-Host $el.Name -ForegroundColor Cyan $reg_type = $el.Name $reg_value = $el.Key } } $out_item = New-Object PSObject -Property @{'RegPath' = $reg_value; 'RegType' = $reg_type; 'PolicyTitle' = $policy_name; 'PolicyDescription' = $policy_desc; 'ADMXFile' = $admx_file} $output += $out_item } } else { $reg_value = "$($pol.Key)\$($pol.valueName)" $reg_type = 'REG_DWORD (1)' $out_item = New-Object PSObject -Property @{'RegPath' = $reg_value; 'RegType' = $reg_type; 'PolicyTitle' = $policy_name; 'PolicyDescription' = $policy_desc; 'ADMXFile' = $admx_file } $output += $out_item } } } else { Write-Host "ADML in $language not found: $adml" -ForegroundColor Yellow } } $output | Export-CSV c:\temp\admx.csv -Encoding UTF8