From de4ff8ff0717fedf284a1d15c8780782ee81af74 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Sun, 28 Jun 2020 22:00:27 +0200 Subject: [PATCH] Update --- Private/ConvertTo-LocalUserAndGroups.ps1 | 89 ++++++++++++++++++++++ Private/ConvertTo-Policies.ps1 | 30 ++++++++ Private/ConvertTo-RegistryAutologon.ps1 | 2 - Private/ConvertTo-Scripts.ps1 | 26 +++++++ Private/ConvertTo-SoftwareInstallation.ps1 | 42 ++++++++++ Private/Script.GPODictionary.ps1 | 28 +++++++ 6 files changed, 215 insertions(+), 2 deletions(-) create mode 100644 Private/ConvertTo-LocalUserAndGroups.ps1 create mode 100644 Private/ConvertTo-Policies.ps1 create mode 100644 Private/ConvertTo-Scripts.ps1 create mode 100644 Private/ConvertTo-SoftwareInstallation.ps1 diff --git a/Private/ConvertTo-LocalUserAndGroups.ps1 b/Private/ConvertTo-LocalUserAndGroups.ps1 new file mode 100644 index 0000000..67c0cf8 --- /dev/null +++ b/Private/ConvertTo-LocalUserAndGroups.ps1 @@ -0,0 +1,89 @@ +function ConvertTo-LocalUserAndGroups { + [cmdletBinding()] + param( + [Array] $GPOList + ) + foreach ($GPOEntry in $GPOList) { + foreach ($User in $GPOEntry.User) { + $CreateGPO = [ordered]@{ + DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level + DomainName = $GPOEntry.DomainName #: area1.local + GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5 + GpoType = $GPOEntry.GpoType #: Computer + GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings + GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions + Changed = [DateTime] $User.Changed + GPOSettingOrder = $User.GPOSettingOrder + UserAction = $User.Properties.action #: U + UserNewName = $User.Properties.newName #: + UserFullName = $User.Properties.fullName #: + UserDescription = $User.Properties.description #: + UserCpassword = $User.Properties.cpassword #: + UserChangeLogon = $User.Properties.changeLogon #: 0 + UserNoChange = $User.Properties.noChange #: 0 + UserNeverExpires = $User.Properties.neverExpires #: 0 + UserAcctDisabled = $User.Properties.acctDisabled #: 0 + UserAubAuthority = $User.Properties.subAuthority #: RID_ADMIN + UserUserName = $User.Properties.userName #: Administrator (built-in) + UserMembers = $User.Properties.Members #: + } + $CreateGPO['Linked'] = $GPOEntry.Linked #: True + $CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1 + $CreateGPO['Links'] = $GPOEntry.Links #: area1.local + [PSCustomObject] $CreateGPO + } + foreach ($Group in $GPOEntry.Group) { + # We're mostly interested in Members + [Array] $Members = foreach ($Member in $Group.Properties.Members.Member) { + [ordered] @{ + MemberName = $Member.Name + MemberAction = $Member.Action + MemberSID = $Member.SID + } + } + # if we have no members we create dummy object to make sure we can use foreach below + if ($Members.Count -eq 0) { + $Members = @( + [ordered] @{ + MemberName = $null + MemberAction = $null + MemberSID = $null + } + ) + } + foreach ($Member in $Members) { + $CreateGPO = [ordered]@{ + DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level + DomainName = $GPOEntry.DomainName #: area1.local + GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5 + GpoType = $GPOEntry.GpoType #: Computer + GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings + GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions + Changed = [DateTime] $Group.Changed + GPOSettingOrder = $Group.GPOSettingOrder + GroupUid = $Group.uid #: {8F435B0A-CD15-464E-85F3-B6A55B9E816A}: {8F435B0A-CD15-464E-85F3-B6A55B9E816A} + GroupUserContext = $Group.userContext #: 0: 0 + GroupRemovePolicy = $Group.removePolicy #: 1: 1 + #Properties = $Group.Properties #: Properties: Properties + Filters = $Group.Filters #:: + + GroupAction = $Group.Properties.action #: U + GroupNewName = $Group.Properties.newName #: + GroupDescription = $Group.Properties.description #: + GroupDeleteAllUsers = $Group.Properties.deleteAllUsers #: 0 + GroupDeleteAllGroups = $Group.Properties.deleteAllGroups #: 0 + GroupRemoveAccounts = $Group.Properties.removeAccounts #: 1 + GroupSid = $Group.Properties.groupSid #: S - 1 - 5 - 32 - 544 + GroupName = $Group.Properties.groupName #: Administrators (built -in ) + } + # Merging GPO with Member + $CreateGPO = $CreateGPO + $Member + + $CreateGPO['Linked'] = $GPOEntry.Linked #: True + $CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1 + $CreateGPO['Links'] = $GPOEntry.Links #: area1.local + [PSCustomObject] $CreateGPO + } + } + } +} diff --git a/Private/ConvertTo-Policies.ps1 b/Private/ConvertTo-Policies.ps1 new file mode 100644 index 0000000..b9a3413 --- /dev/null +++ b/Private/ConvertTo-Policies.ps1 @@ -0,0 +1,30 @@ +function ConvertTo-Policies { + [cmdletBinding()] + param( + [Array] $GPOList + ) + foreach ($GPOEntry in $GPOList) { + $CreateGPO = [ordered]@{ + DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level + DomainName = $GPOEntry.DomainName #: area1.local + GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5 + GpoType = $GPOEntry.GpoType #: Computer + GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings + GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions + PolicyName = $GPOEntry.Name + PolicyState = $GPOEntry.State + PolicyCategory = $GPOEntry.Category + PolicySupported = $GPOEntry.Supported + PolicyExplain = $GPOEntry.Explain + PolicyText = $GPOEntry.Text + PolicyCheckBox = $GPOEntry.CheckBox + PolicyDropDownList = $GPOEntry.DropDownList + PolicyEditText = $GPOEntry.EditText + } + $CreateGPO['Linked'] = $GPOEntry.Linked #: True + $CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1 + $CreateGPO['Links'] = $GPOEntry.Links #: area1.local + [PSCustomObject] $CreateGPO + + } +} \ No newline at end of file diff --git a/Private/ConvertTo-RegistryAutologon.ps1 b/Private/ConvertTo-RegistryAutologon.ps1 index 7349a12..80ff27f 100644 --- a/Private/ConvertTo-RegistryAutologon.ps1 +++ b/Private/ConvertTo-RegistryAutologon.ps1 @@ -12,8 +12,6 @@ GpoType = $GPOEntry.GpoType #: Computer GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions - #Changed = [DateTime] $Registry.changed - GPOSettingOrder = $Registry.GPOSettingOrder AutoAdminLogon = $null DefaultDomainName = $null DefaultUserName = $null diff --git a/Private/ConvertTo-Scripts.ps1 b/Private/ConvertTo-Scripts.ps1 new file mode 100644 index 0000000..05eb078 --- /dev/null +++ b/Private/ConvertTo-Scripts.ps1 @@ -0,0 +1,26 @@ +function ConvertTo-Scripts { + [cmdletBinding()] + param( + [Array] $GPOList + ) + foreach ($GPOEntry in $GPOList) { + $CreateGPO = [ordered]@{ + DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level + DomainName = $GPOEntry.DomainName #: area1.local + GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5 + GpoType = $GPOEntry.GpoType #: Computer + GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings + GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions + Command = $GPOEntry.Command + Parameters = $GPOEntry.Parameters + Type = $GPOEntry.Type + Order = $GPOEntry.Order + RunOrder = $GPOEntry.RunOrder + } + $CreateGPO['Linked'] = $GPOEntry.Linked #: True + $CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1 + $CreateGPO['Links'] = $GPOEntry.Links #: area1.local + [PSCustomObject] $CreateGPO + + } +} \ No newline at end of file diff --git a/Private/ConvertTo-SoftwareInstallation.ps1 b/Private/ConvertTo-SoftwareInstallation.ps1 new file mode 100644 index 0000000..9380d77 --- /dev/null +++ b/Private/ConvertTo-SoftwareInstallation.ps1 @@ -0,0 +1,42 @@ +function ConvertTo-SoftwareInstallation { + [cmdletBinding()] + param( + [Array] $GPOList + ) + foreach ($GPOEntry in $GPOList) { + $CreateGPO = [ordered]@{ + DisplayName = $GPOEntry.DisplayName #: WO_SEC_NTLM_Auth_Level + DomainName = $GPOEntry.DomainName #: area1.local + GUID = $GPOEntry.GUID #: 364B095E-C7BF-4CC1-9BFA-393BD38975E5 + GpoType = $GPOEntry.GpoType #: Computer + GpoCategory = $GPOEntry.GpoCategory #: SecuritySettings + GpoSettings = $GPOEntry.GpoSettings #: SecurityOptions + Identifier = $GPOEntry.Identifier #: { 10495e9e-79c1-4a32-b278-a24cd495437f } + Name = $GPOEntry.Name #: Local Administrator Password Solution (2) + Path = $GPOEntry.Path #: \\area1.local\SYSVOL\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\LAPS.x64.msi + MajorVersion = $GPOEntry.MajorVersion #: 6 + MinorVersion = $GPOEntry.MinorVersion #: 2 + LanguageId = $GPOEntry.LanguageId #: 1033 + Architecture = $GPOEntry.Architecture #: 9 + IgnoreLanguage = if ($GPOEntry.IgnoreLanguage -eq 'true') { $true } else { $false } #: false + Allowx86Onia64 = if ($GPOEntry.Allowx86Onia64 -eq 'true') { $true } else { $false } #: true + SupportURL = $GPOEntry.SupportURL #: + AutoInstall = if ($GPOEntry.AutoInstall -eq 'true') { $true } else { $false } #: true + DisplayInARP = if ($GPOEntry.DisplayInARP -eq 'true') { $true } else { $false } #: true + IncludeCOM = if ($GPOEntry.IncludeCOM -eq 'true') { $true } else { $false } #: true + SecurityDescriptor = $GPOEntry.SecurityDescriptor #: SecurityDescriptor + DeploymentType = $GPOEntry.DeploymentType #: Assign + ProductId = $GPOEntry.ProductId #: { ea8cb806-c109 - 4700 - 96b4-f1f268e5036c } + ScriptPath = $GPOEntry.ScriptPath #: \\area1.local\SysVol\area1.local\Policies\ { 5F5042A0-008F-45E3-8657-79C87BD002E3 }\Machine\Applications\ { EAC9B821-FB4D - 457A-806F-E5B528D1E41A }.aas + DeploymentCount = $GPOEntry.DeploymentCount #: 0 + InstallationUILevel = $GPOEntry.InstallationUILevel #: Maximum + Upgrades = if ($GPOEntry.Upgrades.Mandatory -eq 'true') { $true } else { $false } #: Upgrades + UninstallUnmanaged = if ($GPOEntry.UninstallUnmanaged -eq 'true') { $true } else { $false } #: false + LossOfScopeAction = $GPOEntry.LossOfScopeAction #: Unmanage + } + $CreateGPO['Linked'] = $GPOEntry.Linked #: True + $CreateGPO['LinksCount'] = $GPOEntry.LinksCount #: 1 + $CreateGPO['Links'] = $GPOEntry.Links #: area1.local + [PSCustomObject] $CreateGPO + } +} \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index 9943da4..2153a5f 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -6,6 +6,20 @@ ConvertTo-RegistryAutologon -GPOList $GPOList } } + LocalUsersAndGroups = [ordered] @{ + Category = 'LugsSettings' + Settings = 'LocalUsersAndGroups' + Code = { + ConvertTo-LocalUserAndGroups -GPOList $GPOList + } + } + Policies = @{ + Category = 'RegistrySettings' + Settings = 'Policy' + Code = { + ConvertTo-Policies -GPOList $GPOList + } + } RegistrySettings = [ordered] @{ Category = 'RegistrySettings' Settings = 'RegistrySettings' @@ -20,6 +34,13 @@ ConvertTo-RegistrySettingsCollection -GPOList $GPOList } } + Scripts = [ordered] @{ + Category = 'Scripts' + Settings = 'Script' + Code = { + ConvertTo-Scripts -GPOList $GPOList + } + } SecurityOptions = [ordered] @{ Category = 'SecuritySettings' Settings = 'SecurityOptions' @@ -27,6 +48,13 @@ ConvertTo-SecurityOptions -GPOList $GPOList } } + SoftwareInstallation = [ordered] @{ + Category = 'SoftwareInstallationSettings' + Settings = 'MsiApplication' + Code = { + ConvertTo-SoftwareInstallation -GPOList $GPOList + } + } SystemServices = [ordered] @{ Description = '' GPOPath = 'Computer Configuration -> Policies -> Windows Settings -> Security Settings -> System Services'