Hi Experts,

I am working on creating the image for windows 10 21H2 and I need to add a folder under Windows defender exclusion for example "c:\users\user\appdata\local\folder1"

using PowerShell command "add-MpPreference -ExclusionPath "$($env:LOCALAPPDATA)\folder1" -force", i converted this PowerShell to EXE and added to run once registry and this works after OOBE for the first user.

But the request is to get this exception added to all the users logging into the pc. I have tried to use the same EXE under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run but the setting is not getting applied Under Exclusion, tried to create run once registry under HKU\default user\ but still the exclusion is not getting added under Windows defender.

Kindly suggest on how we can add exclusion to all the user logging into the pc and this has to be ran only once at the first logon for the user.

Thanks
Bala