From 0bf093351f1b80d531e8fa63d300e1b6c2a8f98a Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Fri, 31 Jul 2020 11:00:57 +0200 Subject: [PATCH] Added LAPS support --- Private/ConvertTo-XMLLaps.ps1 | 46 ++++++++++++++++++++++++++++++++ Private/Script.GPODictionary.ps1 | 14 ++++++++++ 2 files changed, 60 insertions(+) create mode 100644 Private/ConvertTo-XMLLaps.ps1 diff --git a/Private/ConvertTo-XMLLaps.ps1 b/Private/ConvertTo-XMLLaps.ps1 new file mode 100644 index 0000000..5fd6d59 --- /dev/null +++ b/Private/ConvertTo-XMLLaps.ps1 @@ -0,0 +1,46 @@ +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 + } +} \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index 2a5b1a7..009d0e8 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -92,6 +92,20 @@ ConvertTo-XMLEventLog -GPO $GPO } } + LAPS = @{ + Types = @( + @{ + Category = 'RegistrySettings' + Settings = 'Policy' + } + ) + Code = { + ConvertTo-XMLLaps -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLLaps -GPO $GPO + } + } LocalUsers = [ordered] @{ Types = @( @{