Update - but maybe we should remove this

This commit is contained in:
Przemyslaw Klys
2020-08-01 00:12:03 +02:00
parent 7afd104b7b
commit e512c0b0de
2 changed files with 79 additions and 10 deletions
+65
View File
@@ -0,0 +1,65 @@
function ConvertTo-XMLBitlocker {
[cmdletBinding()]
param(
[PSCustomObject] $GPO
)
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
}
$UsedNames = [System.Collections.Generic.List[string]]::new()
if ($GPO.DataSet.Category -like 'Windows Components/BitLocker Drive Encryption*') {
foreach ($Policy in $GPO.DataSet) {
$Name = Format-ToTitleCase -Text $Policy.Name -RemoveWhiteSpace -RemoveChars ',', '-', "'", '\(', '\)', ':'
$CreateGPO[$Name] = $Policy.State
foreach ($Setting in @('DropDownList', 'Numeric', 'EditText', 'Text', 'CheckBox')) {
if ($Policy.$Setting) {
foreach ($Value in $Policy.$Setting) {
if ($Value.Name) {
$SubName = Format-ToTitleCase -Text $Value.Name -RemoveWhiteSpace -RemoveChars ',', '-', "'", '\(', '\)', ':'
$SubName = -join ($Name, $SubName)
if ($SubName -notin $UsedNames) {
$UsedNames.Add($SubName)
} else {
$TimesUsed = $UsedNames | Group-Object | Where-Object { $_.Name -eq $SubName }
$NumberToUse = $TimesUsed.Count + 1
# We add same name 2nd and 3rd time to make sure we count properly
$UsedNames.Add($SubName)
# We now build property name based on amnount of times
$SubName = -join ($SubName, "$NumberToUse")
}
if ($Value.Value -is [string]) {
if ($null -eq $Value.Value -and $CreateGPO["$SubName"]) {
# if value is empty and we already have set value (such as Disabled) - we do nothing
} else {
$CreateGPO["$SubName"] = $Value.Value
}
} elseif ($Value.State) {
$CreateGPO["$SubName"] = $Value.State
} elseif ($null -eq $Value.Value) {
# Do nothing, usually it's just a text to display
# Write-Verbose "Skipping value for display because it's empty. Name: $($Value.Name)"
} else {
if ($null -eq $Value.Value.Name -and $CreateGPO["$SubName"]) {
# if value is empty and we already have set value (such as Disabled) - we do nothing
} else {
$CreateGPO["$SubName"] = $Value.Value.Name
}
}
}
}
}
}
}
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
}
}
+14 -10
View File
@@ -12,7 +12,6 @@ function ConvertTo-XMLLithnetFilter {
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
DisablePasswordFilter = 'Not set' # : Disabled
EnableLengthBasedComplexityRules = $null # : Enabled
EnableLengthBasedComplexityRulesApplyTheFollowingRequirementsForPasswordsWithALengthLessThan = $null # : 9
@@ -20,13 +19,13 @@ function ConvertTo-XMLLithnetFilter {
EnableLengthBasedComplexityRulesApplyTheFollowingRequirementsForPasswordsLongerThanTheFirstThresholdButWithALengthLessThan = $null # : 15
EnableLengthBasedComplexityRulesTotalNumberOfCharacterSetsRequiredNumberSymbolUppercaseLetterLowercaseLetter2 = $null # : 4
EnableLengthBasedComplexityRulesTotalNumberOfCharacterSetsRequiredNumberSymbolUppercaseLetterLowercaseLetter3 = $null # : 4
EnableLengthBasedComplexityRulesThresholdLevel1 = $null # :
EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired = $null # :
EnableLengthBasedComplexityRulesThresholdLevel2 = $null # :
EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired2 = $null # :
EnableLengthBasedComplexityRulesThresholdLevel3 = $null # :
EnableLengthBasedComplexityRulesForPasswordsLongerThanTheSecondThresholdApplyTheFollowingRequirements = $null # :
EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired3 = $null # :
#EnableLengthBasedComplexityRulesThresholdLevel1 = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired = $null # :
#EnableLengthBasedComplexityRulesThresholdLevel2 = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired2 = $null # :
#EnableLengthBasedComplexityRulesThresholdLevel3 = $null # :
#EnableLengthBasedComplexityRulesForPasswordsLongerThanTheSecondThresholdApplyTheFollowingRequirements = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired3 = $null # :
EnableLengthBasedComplexityRulesLowerCaseLetter = 'Disabled' # :
EnableLengthBasedComplexityRulesUpperCaseLetter = 'Disabled' # :
EnableLengthBasedComplexityRulesSymbol = 'Disabled' # :
@@ -74,14 +73,14 @@ function ConvertTo-XMLLithnetFilter {
$UsedNames = [System.Collections.Generic.List[string]]::new()
if ($GPO.DataSet.Category -like 'Lithnet/Password Protection for Active Directory*') {
foreach ($Policy in $GPO.DataSet) {
$Name = (Format-ToTitleCase -Text $Policy.Name -RemoveWhiteSpace) -replace ',' -replace '-' -replace "'"
$Name = Format-ToTitleCase -Text $Policy.Name -RemoveWhiteSpace -RemoveChars ',', '-', "'", '\(', '\)', ':'
$CreateGPO[$Name] = $Policy.State
foreach ($Setting in @('DropDownList', 'Numeric', 'EditText', 'Text', 'CheckBox')) {
if ($Policy.$Setting) {
foreach ($Value in $Policy.$Setting) {
if ($Value.Name) {
$SubName = (Format-ToTitleCase -Text $Value.Name -RemoveWhiteSpace) -replace ',' -replace '-' -replace "'" -replace '\(' -replace '\)'
$SubName = Format-ToTitleCase -Text $Value.Name -RemoveWhiteSpace -RemoveChars ',', '-', "'", '\(', '\)', ':'
$SubName = -join ($Name, $SubName)
if ($SubName -notin $UsedNames) {
$UsedNames.Add($SubName)
@@ -99,6 +98,11 @@ function ConvertTo-XMLLithnetFilter {
} else {
$CreateGPO["$SubName"] = $Value.Value
}
} elseif ($Value.State) {
$CreateGPO["$SubName"] = $Value.State
} elseif ($null -eq $Value.Value) {
# Do nothing, usually it's just a text to display
# Write-Verbose "Skipping value for display because it's empty. Name: $($Value.Name)"
} else {
if ($null -eq $Value.Value.Name -and $CreateGPO["$SubName"]) {
# if value is empty and we already have set value (such as Disabled) - we do nothing