Windows 环境排除 Windows Defender 对指定路径或进程的影响
文章目录
- 背景说明
- 排除路径
- 查看所有已排除的路径
- 查看所有已排除的进程
- 删除 "对进程排除" 的设置
- 删除 "对路径排除" 的设置
背景说明
Add-MpPreference 是 Windows Defender 的 PowerShell 命令,用于 将文件、文件夹或进程添加到排除列表中,
防止其被 Windows Defender 实时保护扫描,从而避免对性能敏感操作(如 PostgreSQL 的 fsync)造成影响。
排除路径
$productDir = "E:\PostgreSQL"
Add-MpPreference -ExclusionPath $productDir
经济```# 排除进程
```bash
$pgProcess = "E:\PostgreSQL\pgsql\bin\postgres.exe"
$pgctlProcess = "E:\PostgreSQL\pgsql\bin\pg_ctl.exe"
$psqlProcess = "E:\PostgreSQL\pgsql\bin\psql.exe"
Add-MpPreference -ExclusionProcess $pgProcess
Add-MpPreference -ExclusionProcess $pgctlProcess
Add-MpPreference -ExclusionProcess $psqlProcess
查看所有已排除的路径
Get-MpPreference | Select-Object -ExpandProperty ExclusionPath
查看所有已排除的进程
Get-MpPreference | Select-Object -ExpandProperty ExclusionProcess
删除 “对进程排除” 的设置
Remove-
MpPreference -ExclusionProcess $pgProcess
Remove-MpPreference -ExclusionProcess $pgctlProcess
Remove-MpPreference -ExclusionProcess $psqlProcess
删除 “对路径排除” 的设置
Remove-MpPreference -ExclusionPath $productDir