4
4
$DependencyPath = (Resolve-Path " $PSScriptRoot \requiredModules.psd1" ).Path,
5
5
6
6
[string ]
7
- $OutputPath = (Resolve-Path " $PSScriptRoot \..\output" ).Path
7
+ $OutputPath = (Resolve-Path " $PSScriptRoot \..\output" ).Path,
8
+
9
+ [string ]
10
+ $SourcePath = " $PSScriptRoot \..\configurationdata"
8
11
)
9
12
10
13
$psdependConfig = Import-PowerShellDataFile - Path $DependencyPath
11
14
$modPath = Resolve-Path - Path $psdependConfig.PSDependOptions.Target
12
15
$modOld = $env: PSModulePath
13
16
$pathSeparator = [System.IO.Path ]::PathSeparator
14
17
$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 )
16
20
17
21
foreach ($policy in (Get-ChildItem - Path (Join-Path - Path $OutputPath - ChildPath Policies) - Recurse - Filter * .xml))
18
22
{
@@ -25,10 +29,30 @@ foreach ($policy in (Get-ChildItem -Path (Join-Path -Path $OutputPath -ChildPath
25
29
$null = New-GPO - Name $policy.BaseName - Comment " Auto-updated applocker policy" - Domain $policy.Directory.Name
26
30
}
27
31
28
- $rsop = $rsops | Where-Object { $_.Name -eq $policy.BaseName }
32
+ $rsop = $rsops | Where-Object { $_ [ ' PolicyName ' ] -eq $policy.BaseName }
29
33
foreach ($link in $rsop.Links )
30
34
{
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
32
56
}
33
57
34
58
$policyFound = $searcher.FindOne ()
0 commit comments