44 $DependencyPath = (Resolve-Path " $PSScriptRoot \requiredModules.psd1" ).Path,
55
66 [string ]
7- $OutputPath = (Resolve-Path " $PSScriptRoot \..\output" ).Path
7+ $OutputPath = (Resolve-Path " $PSScriptRoot \..\output" ).Path,
8+
9+ [string ]
10+ $SourcePath = " $PSScriptRoot \..\configurationdata"
811)
912
1013$psdependConfig = Import-PowerShellDataFile - Path $DependencyPath
1114$modPath = Resolve-Path - Path $psdependConfig.PSDependOptions.Target
1215$modOld = $env: PSModulePath
1316$pathSeparator = [System.IO.Path ]::PathSeparator
1417$env: PSModulePath = " $modPath$pathSeparator$modOld "
15- $rsops = Get-DatumRsopCache
18+ $datum = New-DatumStructure - DefinitionFile (Join-Path $SourcePath Datum.yml)
19+ [hashtable []] $rsops = Get-DatumRsop $datum (Get-DatumNodesRecursive - AllDatumNodes $Datum.AllNodes )
1620
1721foreach ($policy in (Get-ChildItem - Path (Join-Path - Path $OutputPath - ChildPath Policies) - Recurse - Filter * .xml))
1822{
@@ -25,10 +29,30 @@ foreach ($policy in (Get-ChildItem -Path (Join-Path -Path $OutputPath -ChildPath
2529 $null = New-GPO - Name $policy.BaseName - Comment " Auto-updated applocker policy" - Domain $policy.Directory.Name
2630 }
2731
28- $rsop = $rsops | Where-Object { $_.Name -eq $policy.BaseName }
32+ $rsop = $rsops | Where-Object { $_ [ ' PolicyName ' ] -eq $policy.BaseName }
2933 foreach ($link in $rsop.Links )
3034 {
31- Set-GPLink - Name $rsop.PolicyName - Target $link.OrgUnitDn - LinkEnabled $link.Enabled - Enforced $link.Enforced - Order $link.Order - Domain $policy.Directory.Name - Confirm:0
35+ $param = @ {
36+ Name = $rsop.PolicyName
37+ Target = $link.OrgUnitDn
38+ Domain = $policy.Directory.Name
39+ Confirm = $false
40+ }
41+
42+ if ($rsop.ContainsKey (' Enabled' ))
43+ {
44+ $param [' LinkEnabled' ] = $link.Enabled
45+ }
46+ if ($rsop.ContainsKey (' Enforced' ))
47+ {
48+ $param [' Enforced' ] = $link.Enforced
49+ }
50+ if ($rsop.ContainsKey (' Order' ))
51+ {
52+ $param [' Order' ] = $link.Order
53+ }
54+
55+ Set-GPLink @param
3256 }
3357
3458 $policyFound = $searcher.FindOne ()
0 commit comments