Files
claudetools/clients/cascades-tucson/scripts/applocker-to-gpo.ps1
Howard Enos 5076f8f4b1 sync: auto-sync from HOWARD-HOME at 2026-07-17 14:35:21
Author: Howard Enos
Machine: HOWARD-HOME
Timestamp: 2026-07-17 14:35:21
2026-07-17 14:35:55 -07:00

23 lines
1.2 KiB
PowerShell

Import-Module GroupPolicy
$gpoName = 'CSC - Caregiver Device Lockdown'
$xmlPath = "\\cascades.local\SYSVOL\cascades.local\scripts\applocker-caregiver.xml"
$xml = Get-Content $xmlPath -Raw
Set-AppLockerPolicy -XmlPolicy $xmlPath -Ldap "LDAP://$(([ADSI]'').distinguishedName)" -ErrorAction SilentlyContinue
# AppLocker GPO needs to be set via registry in the GPO
# HKLM\SOFTWARE\Policies\Microsoft\Windows\SrpV2\Appx
$gpo = Get-GPO -Name $gpoName
$base = 'HKLM\SOFTWARE\Policies\Microsoft\Windows\SrpV2\Appx'
Set-GPRegistryValue -Guid $gpo.Id -Key $base -ValueName 'EnforcementMode' -Type String -Value '1' | Out-Null
# Parse XML to extract individual rules
[xml]$doc = $xml
$rules = $doc.AppLockerPolicy.RuleCollection | Where-Object { $_.Type -eq 'Appx' }
foreach ($rule in $rules.FilePublisherRule) {
$ruleXml = $rule.OuterXml
Set-GPRegistryValue -Guid $gpo.Id -Key "$base\$($rule.Id)" -ValueName 'Value' -Type String -Value $ruleXml | Out-Null
Write-Output "GPO rule: $($rule.Name)"
}
Write-Output "AppLocker rules written to GPO: $gpoName"
# Enable AppIDSvc via GPO
Set-GPRegistryValue -Guid $gpo.Id -Key 'HKLM\SYSTEM\CurrentControlSet\Services\AppIDSvc' -ValueName 'Start' -Type DWord -Value 2 | Out-Null
Write-Output "AppIDSvc set to Automatic in GPO"