Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Allow all blocked apps to Windows Defender's Controlled folder access (interactively)
$appEvents = Get-WinEvent -LogName "Microsoft-Windows-Windows Defender/Operational" |
Where-Object {$_.Id -eq "1123"}
$allBlockedProcesses = (
$appEvents |
ForEach-Object {
(([xml]$_.ToXml()).Event.EventData.Data |
Where-Object {
$_.Name -eq "Process Name"
}).'#text'
} |
Sort-Object -Unique
)
$currentWhiteList = (Get-MpPreference).ControlledFolderAccessAllowedApplications
if ($allBlockedProcesses -eq $null) {
Write-Host -ForegroundColor Red "No Processes have been filtered"
exit 3
}
if ($currentWhiteList -eq $null) {
$newProcesses = $allBlockedProcesses
}
else {
$newProcesses = Compare-Object `
-ReferenceObject $allBlockedProcesses `
-DifferenceObject $currentWhiteList |
Where-Object {
$_.SideIndicator -eq '<='
} |
Select-Object -ExpandProperty InputObject
}
if ($newProcesses -eq $null) {
Write-Host -ForegroundColor Green "All processes have already been added"
exit 0
}
$newProcesses |
Out-GridView -PassThru |
ForEach-Object {
Add-MpPreference -ControlledFolderAccessAllowedApplications $_
}
@grrunnz

This comment has been minimized.

Copy link

commented May 16, 2018

On my PC the id for the events changed from 1123 to 1127

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.