Skip to content

Commit d7b0abc

Browse files
committed
Include GPLinks in publishing process
1 parent 4284d11 commit d7b0abc

File tree

2 files changed

+29
-5
lines changed

2 files changed

+29
-5
lines changed

templates/AppLockerProject/azurepipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ jobs:
7373
displayName: Publish policies
7474
inputs:
7575
filePath: '.\build\publish.ps1'
76-
arguments: '-DependencyPath (Join-Path $(Build.SourcesDirectory) build\requiredModules.psd1) -OutputPath (Join-Path $(Build.SourcesDirectory) output)'
76+
arguments: '-DependencyPath (Join-Path $(Build.SourcesDirectory) build\requiredModules.psd1) -SourcePath (Join-Path $(Build.SourcesDirectory) configurationdata) -OutputPath (Join-Path $(Build.SourcesDirectory) output)'
7777
- task: PowerShell@2
7878
name: validateintegration
7979
displayName: Validate Integration

templates/AppLockerProject/build/publish.ps1

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@ param
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

1721
foreach ($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

Comments
 (0)