简体   繁体   中英

Activating rule 16 of WDAC doesnt allow to apply policy without rebooting

I'm applying wdac using commands when I have enforced mode I try changing it to enforced mode but it doesn't work without the reboot with the Rule 16 activated, I have tried using gpupdate /force but it doesn't work either, any ideas?

(W10 version 1809)

The policy is correctly enabled

This is the code I'm using:

$Policy="C:\Policies\Policy.xml"
$DeviceGuardPolicy="C:\Policies\DeviceGuardPolicy.bin"
$LGPOTxt="C:\Policies\LGPO\LGPO.txt" #Txt generated after lgpo backup
$WL="C:\Policies"
$SIPolicy="C:\Windows\System32\CodeIntegrity\SiPolicy.p7b"

  Disable-WdacPolicy
  rm $SiPolicy
  Set-RuleOption -FilePath $Policy -Option 3 
  ConvertFrom-CIPolicy $Policy $DeviceGuardPolicy
  ConvertFrom-CIPolicy -XmlFilePath $Policy -BinaryFilePath $SIPolicy 
  Enable-WdacPolicy

$ActivatePolicy="Computer`r`nSOFTWARE\Policies\Microsoft\Windows\DeviceGuard`r`nDeployConfigCIPolicy`r`nDWORD:1`r`n`r`nComputer`r`nSOFTWARE\Policies\Microsoft\Windows\DeviceGuard`r`nConfigCIPolicyFilePath`r`nSZ:C:\\WL\\politicas\\DeviceGuardPolicy.bin"
$DesactivatePolicy="Computer`r`nSOFTWARE\Policies\Microsoft\Windows\DeviceGuard`r`nDeployConfigCIPolicy`r`nDELETE`r`n`r`nComputer`r`nSOFTWARE\Policies\Microsoft\Windows\DeviceGuard`r`nConfigCIPolicyFilePath`r`nDELETE"

function Enable-WdacPolicy
{
  (Get-Content -path $LGPOTxt -Raw).replace($DesactivatePolicy, $ActivatePolicy) | Set-Content -Path $LGPOTxt
    cd $WL
    .\LGPO.exe /t $LGPOTxt
    ConvertFrom-CIPolicy -XmlFilePath $Policy -BinaryFilePath $SIPolicy 
    gpupdate /force
  }
}

function Disable-WdacPolicy
{
    (Get-Content -path $LGPOTxt -Raw).replace($ActivatePolicy, $DesactivatePolicy) | Set-Content -Path $LGPOTxt
    cd $WL
    .\LGPO.exe /t $LGPOTxt
    gpupdate /force
  }
}

I found this solution

Invoke-CimMethod -Namespace root\Microsoft\Windows\CI -ClassName PS_UpdateAndCompareCIPolicy -MethodName Update -Arguments @{FilePath = $DestinationBinary}

Adding this line of code after gpupdate /force refresh the policy in msinfo32.exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM