You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
rdpwrap/RdpCoexist/modules/Defender.psm1

26 lines
911 B

Set-StrictMode -Version Latest
function Add-DefenderExclusion {
param([Parameter(Mandatory)][string]$Path)
try {
$cur = @((Get-MpPreference).ExclusionPath)
if ($cur -notcontains $Path) {
Add-MpPreference -ExclusionPath $Path
Write-Log "Defender exclusion added: $Path" 'Ok'
}
else { Write-Log "Defender exclusion already present: $Path" }
}
catch {
# If exclusions are locked by Intune/Tenant, only IT can add them.
Write-Log "Could not add Defender exclusion (managed by policy?): $_" 'Warn'
}
}
function Remove-DefenderExclusion {
param([Parameter(Mandatory)][string]$Path)
try { Remove-MpPreference -ExclusionPath $Path -ErrorAction SilentlyContinue }
catch { Write-Log "Could not remove Defender exclusion: $_" 'Warn' }
}
Export-ModuleMember -Function Add-DefenderExclusion, Remove-DefenderExclusion