From 9172948be31763d75100800eb8ca72b919ffc805 Mon Sep 17 00:00:00 2001 From: Przemyslaw Klys Date: Wed, 10 Feb 2021 19:50:45 +0100 Subject: [PATCH] Added folder redirection #12 --- Private/ConvertTo-XMLFolderRedirection.ps1 | 70 ++++++++++++++++++++++ Private/Script.GPODictionary.ps1 | 15 +++++ 2 files changed, 85 insertions(+) create mode 100644 Private/ConvertTo-XMLFolderRedirection.ps1 diff --git a/Private/ConvertTo-XMLFolderRedirection.ps1 b/Private/ConvertTo-XMLFolderRedirection.ps1 new file mode 100644 index 0000000..fe99af1 --- /dev/null +++ b/Private/ConvertTo-XMLFolderRedirection.ps1 @@ -0,0 +1,70 @@ +function ConvertTo-XMLFolderRedirection { + [cmdletBinding()] + param( + [PSCustomObject] $GPO, + [switch] $SingleObject + ) + if ($SingleObject) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + #GpoCategory = $GPOEntry.GpoCategory + #GpoSettings = $GPOEntry.GpoSettings + Count = 0 + Settings = $null + } + [Array] $CreateGPO['Settings'] = foreach ($Folder in $GPO.DataSet) { + foreach ($Location in $Folder.Location) { + [PSCustomObject] @{ + DestinationPath = $Location.DestinationPath + SecuritySID = $Location.SecurityGroup.SID.'#text' + SecurityName = $Location.SecurityGroup.Name.'#text' + GrantExclusiveRights = if ($Folder.GrantExclusiveRights -eq 'true') { $true } else { $false } + MoveContents = if ($Folder.MoveContents -eq 'true') { $true } else { $false } + FollowParent = if ($Folder.FollowParent -eq 'true') { $true } else { $false } + ApplyToDownLevel = if ($Folder.ApplyToDownLevel -eq 'true') { $true } else { $false } + DoNotCare = if ($Folder.DoNotCare -eq 'true') { $true } else { $false } + RedirectToLocal = if ($Folder.RedirectToLocal -eq 'true') { $true } else { $false } + PolicyRemovalBehavior = $Folder.PolicyRemovalBehavior # : LeaveContents + ConfigurationControl = if ($Folder.ConfigurationControl -eq 'GP') { 'Group Policy' } else { $Folder.ConfigurationControl } # : GP + PrimaryComputerEvaluation = $Folder.PrimaryComputerEvaluation # : PrimaryComputerPolicyDisabled + } + } + } + $CreateGPO['Count'] = $CreateGPO['Settings'].Count + $CreateGPO['Linked'] = $GPO.Linked + $CreateGPO['LinksCount'] = $GPO.LinksCount + $CreateGPO['Links'] = $GPO.Links + [PSCustomObject] $CreateGPO + } else { + foreach ($Folder in $GPO.DataSet) { + foreach ($Location in $Folder.Location) { + $CreateGPO = [ordered]@{ + DisplayName = $GPO.DisplayName + DomainName = $GPO.DomainName + GUID = $GPO.GUID + GpoType = $GPO.GpoType + Id = $Folder.Id + DestinationPath = $Location.DestinationPath + SecuritySID = $Location.SecurityGroup.SID.'#text' + SecurityName = $Location.SecurityGroup.Name.'#text' + GrantExclusiveRights = if ($Folder.GrantExclusiveRights -eq 'true') { $true } else { $false } + MoveContents = if ($Folder.MoveContents -eq 'true') { $true } else { $false } + FollowParent = if ($Folder.FollowParent -eq 'true') { $true } else { $false } + ApplyToDownLevel = if ($Folder.ApplyToDownLevel -eq 'true') { $true } else { $false } + DoNotCare = if ($Folder.DoNotCare -eq 'true') { $true } else { $false } + RedirectToLocal = if ($Folder.RedirectToLocal -eq 'true') { $true } else { $false } + PolicyRemovalBehavior = $Folder.PolicyRemovalBehavior # : LeaveContents + ConfigurationControl = if ($Folder.ConfigurationControl -eq 'GP') { 'Group Policy' } else { $Folder.ConfigurationControl } # : GP + PrimaryComputerEvaluation = $Folder.PrimaryComputerEvaluation # : PrimaryComputerPolicyDisabled + Linked = $GPO.Linked + LinksCount = $GPO.LinksCount + Links = $GPO.Links + } + [PSCustomObject] $CreateGPO + } + } + } +} \ No newline at end of file diff --git a/Private/Script.GPODictionary.ps1 b/Private/Script.GPODictionary.ps1 index 175b413..e0cf910 100644 --- a/Private/Script.GPODictionary.ps1 +++ b/Private/Script.GPODictionary.ps1 @@ -336,6 +336,21 @@ } } FolderRedirection = @{ + Types = @( + @{ + Category = 'FolderRedirectionSettings' + Settings = 'Folder' + } + ) + GPOPath = 'Windows Settings -> Folder Redirection' + Code = { + ConvertTo-XMLFolderRedirection -GPO $GPO + } + CodeSingle = { + ConvertTo-XMLFolderRedirection -GPO $GPO -SingleObject + } + } + FolderRedirectionPolicy = @{ Types = @( @{ Category = 'RegistrySettings'