Powershell to add Defender Exclusions for FSLogix

$gpo  = 'C - FSLogix Profile'
$key  = 'HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Exclusions\Paths'
$paths = @(
  '%TEMP%\*\*.VHD', '%TEMP%\*\*.VHDX',
  '%Windir%\TEMP\*\*.VHD', '%Windir%\TEMP\*\*.VHDX'
)
foreach ($share in '\\xxxxx.file.core.windows.net\userprofiles',
                   '\\xxxx.file.core.windows.net\365profiles') {
  foreach ($ext in 'VHD','VHD.lock','VHD.meta','VHD.metadata','VHDX','VHDX.lock','VHDX.meta','VHDX.metadata') {
    $paths += "$share\*\*.$ext"
  }
}
# Turns on the "Path Exclusions" policy setting
Set-GPRegistryValue -Name $gpo -Key 'HKLM\SOFTWARE\Policies\Microsoft\Windows Defender\Exclusions' -ValueName 'Exclusions_Paths' -Type DWord -Value 1
# Each exclusion is a value: name = path, data = "0"
foreach ($p in $paths) { Set-GPRegistryValue -Name $gpo -Key $key -ValueName $p -Type String -Value '0' | Out-Null }
Get-GPRegistryValue -Name $gpo -Key $key | Select ValueName
(No Ratings Yet)