Cleaning up dead code

This commit is contained in:
Przemyslaw Klys
2020-08-02 00:41:05 +02:00
parent acb51d4444
commit 33b2854d63
4 changed files with 0 additions and 281 deletions
-65
View File
@@ -1,65 +0,0 @@
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 -RemoveChar ',', '-', "'", '\(', '\)', ':'
$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 -RemoveChar ',', '-', "'", '\(', '\)', ':'
$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
}
}
-46
View File
@@ -1,46 +0,0 @@
function ConvertTo-XMLLaps {
[cmdletBinding()]
param(
[PSCustomObject] $GPO
)
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
'EnableLocalAdminPasswordManagement' = 'Not set'
'PasswordSettings' = 'Not set'
'PasswordComplexity' = $null
'PasswordLength' = $null
'PasswordAge(Days)' = $null
'AdministratorAccountName' = $null
'NameOfAdministratorAccountToManage' = 'Not set'
'DoNotAllowPasswordExpirationTimeLongerThanRequiredByPolicy' = 'Not set'
}
if ($GPO.DataSet.Category -eq 'LAPS') {
foreach ($Policy in $GPO.DataSet) {
if ($Policy.Category -eq 'LAPS') {
foreach ($Setting in @('DropDownList', 'Numeric', 'EditText')) {
if ($Policy.$Setting) {
foreach ($Value in $Policy.$Setting) {
$Name = Format-ToTitleCase -Text $Value.Name -RemoveWhiteSpace
if ($Value.Value -is [string]) {
$CreateGPO["$Name"] = $Value.Value
} else {
$CreateGPO["$Name"] = $Value.Value.Name
}
}
}
}
$Name = (Format-ToTitleCase -Text $Policy.Name -RemoveWhiteSpace)
$CreateGPO[$Name] = $Policy.State
}
}
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
}
}
-123
View File
@@ -1,123 +0,0 @@
function ConvertTo-XMLLithnetFilter {
[cmdletBinding()]
param(
[PSCustomObject] $GPO,
[switch] $SingleObject
)
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
DisablePasswordFilter = 'Not set' # : Disabled
EnableLengthBasedComplexityRules = $null # : Enabled
EnableLengthBasedComplexityRulesApplyTheFollowingRequirementsForPasswordsWithALengthLessThan = $null # : 9
EnableLengthBasedComplexityRulesTotalNumberOfCharacterSetsRequiredNumberSymbolUppercaseLetterLowercaseLetter = $null # : 4
EnableLengthBasedComplexityRulesApplyTheFollowingRequirementsForPasswordsLongerThanTheFirstThresholdButWithALengthLessThan = $null # : 15
EnableLengthBasedComplexityRulesTotalNumberOfCharacterSetsRequiredNumberSymbolUppercaseLetterLowercaseLetter2 = $null # : 4
EnableLengthBasedComplexityRulesTotalNumberOfCharacterSetsRequiredNumberSymbolUppercaseLetterLowercaseLetter3 = $null # : 4
#EnableLengthBasedComplexityRulesThresholdLevel1 = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired = $null # :
#EnableLengthBasedComplexityRulesThresholdLevel2 = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired2 = $null # :
#EnableLengthBasedComplexityRulesThresholdLevel3 = $null # :
#EnableLengthBasedComplexityRulesForPasswordsLongerThanTheSecondThresholdApplyTheFollowingRequirements = $null # :
#EnableLengthBasedComplexityRulesAlternativelySpecifyTheExactCharacterSetsRequired3 = $null # :
EnableLengthBasedComplexityRulesLowerCaseLetter = 'Disabled' # :
EnableLengthBasedComplexityRulesUpperCaseLetter = 'Disabled' # :
EnableLengthBasedComplexityRulesSymbol = 'Disabled' # :
EnableLengthBasedComplexityRulesNumber = 'Disabled' # :
EnableLengthBasedComplexityRulesNumberOrSymbol = 'Disabled' # :
EnableLengthBasedComplexityRulesLowerCaseLetter2 = 'Disabled' # :
EnableLengthBasedComplexityRulesUpperCaseLetter2 = 'Disabled' # :
EnableLengthBasedComplexityRulesSymbol2 = 'Disabled' # :
EnableLengthBasedComplexityRulesNumber2 = 'Disabled' # :
EnableLengthBasedComplexityRulesNumberOrSymbol2 = 'Disabled' # :
EnableLengthBasedComplexityRulesLowerCaseLetter3 = 'Disabled' # :
EnableLengthBasedComplexityRulesUpperCaseLetter3 = 'Disabled' # :
EnableLengthBasedComplexityRulesSymbol3 = 'Disabled' # :
EnableLengthBasedComplexityRulesNumber3 = 'Disabled' # :
EnableLengthBasedComplexityRulesNumberOrSymbol3 = 'Disabled' # :
MinimumPasswordLength = $null # : Enabled
MinimumPasswordLengthMinimumPasswordLength = $null # : 8
PasswordsMustMatchASpecifiedRegularExpression = $null # : Enabled
PasswordsMustMatchASpecifiedRegularExpressionRegularExpression = $null # : sdf
PasswordsMustMeetSpecifiedNumberOfComplexityPoints = $null # : Enabled
PasswordsMustMeetSpecifiedNumberOfComplexityPointsMinimumNumberOfPointsRequiredForPasswordToBeApproved = $null # : 13
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForEachCharacterUsed = $null # : 1
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForEachNumberUsed = $null # : 0
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForEachLowerCaseLetterUsed = $null # : 0
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForEachUpperCaseLetterUsed = $null # : 0
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsPerSymbolUsed = $null # : 0
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForTheUseOfAtLeastOneNumber = $null # : 1
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForTheUseOfAtLeastOneSymbol = $null # : 2
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForTheUseOfAtLeastOneUppercaseLetter = $null # : 1
PasswordsMustMeetSpecifiedNumberOfComplexityPointsPointsForTheUseOfAtLeastOneLowercaseLetter = $null # : 0
PasswordsMustNotMatchASpecifiedRegularExpression = $null # : Enabled
PasswordsMustNotMatchASpecifiedRegularExpressionRegularExpression = $null # : df
RejectNormalizedPasswordsFoundInTheBannedWordStore = $null # : Enabled
RejectNormalizedPasswordsFoundInTheBannedWordStoreEnableForPasswordSetOperations = $null # :
RejectNormalizedPasswordsFoundInTheBannedWordStoreEnableForPasswordChangeOperations = $null # :
RejectNormalizedPasswordsFoundInTheCompromisedPasswordStore = $null # : Enabled
RejectNormalizedPasswordsFoundInTheCompromisedPasswordStoreEnableForPasswordSetOperations = $null # :
RejectNormalizedPasswordsFoundInTheCompromisedPasswordStoreEnableForPasswordChangeOperations = $null # :
RejectPasswordsFoundInTheCompromisedPasswordStore = $null # : Enabled
RejectPasswordsFoundInTheCompromisedPasswordStoreEnableForPasswordSetOperations = $null # :
RejectPasswordsFoundInTheCompromisedPasswordStoreEnableForPasswordChangeOperations = $null # :
RejectPasswordsThatContainTheUsersAccountName = $null # : Enabled
RejectPasswordsThatContainTheUsersDisplayName = $null # : Enabled
}
$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 -RemoveChar ',', '-', "'", '\(', '\)', ':'
$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 -RemoveChar ',', '-', "'", '\(', '\)', ':'
$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
}
}
-47
View File
@@ -17,59 +17,12 @@
}
[Array] $CreateGPO['Settings'] = Get-XMLNestedRegistry -GPO $GPO -DataSet $GPO.DataSet
<#
[Array] $CreateGPO['Settings'] = foreach ($Registry in $GPO.DataSet.Registry) {
[PSCustomObject] @{
Changed = [DateTime] $Registry.changed
GPOSettingOrder = $Registry.GPOSettingOrder
Hive = $Registry.Properties.hive #: HKEY_LOCAL_MACHINE
Key = $Registry.Properties.key #: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Name = $Registry.Properties.name #: AutoAdminLogon
Type = $Registry.Properties.type #: REG_SZ
Value = $Registry.Properties.value #
Filters = $Registry.Filters
}
}
#>
$CreateGPO['Count'] = $CreateGPO['Settings'].Count
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
} else {
<#
if ($GPO.DataSet.Registry) {
Get-XMLNestedRegistry -GPO $GPO -RegistryCollection $GPO.DataSet.Registry
}
if ($GPO.DataSet.Collection) {
Get-XMLNestedRegistry -GPO $GPO -RegistryCollection $GPO.DataSet.Collection
}
#>
Get-XMLNestedRegistry -GPO $GPO -DataSet $GPO.DataSet
<#
foreach ($Registry in $GPO.DataSet.Registry) {
$CreateGPO = [ordered]@{
DisplayName = $GPO.DisplayName
DomainName = $GPO.DomainName
GUID = $GPO.GUID
GpoType = $GPO.GpoType
#GpoCategory = $GPOEntry.GpoCategory
#GpoSettings = $GPOEntry.GpoSettings
Changed = [DateTime] $Registry.changed
GPOSettingOrder = $Registry.GPOSettingOrder
Hive = $Registry.Properties.hive #: HKEY_LOCAL_MACHINE
Key = $Registry.Properties.key #: SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
Name = $Registry.Properties.name #: AutoAdminLogon
Type = $Registry.Properties.type #: REG_SZ
Value = $Registry.Properties.value #
Filters = $Registry.Filters
}
$CreateGPO['Linked'] = $GPO.Linked
$CreateGPO['LinksCount'] = $GPO.LinksCount
$CreateGPO['Links'] = $GPO.Links
[PSCustomObject] $CreateGPO
}
#>
}
}