通过PowerShell查询并排除Exchange相关进程

# 以管理员身份运行以下脚本
 
# 查询所有含"exchange"的进程
$exchProcesses = Get-Process | Where-Object { $_.Path -match "exchange" } | Select-Object -ExpandProperty Path -Unique
 
# 添加到Defender排除列表
foreach ($process in $exchProcesses) {
Add-MpPreference -ExclusionProcess $process
Write-Host "已排除进程: $process"
}
 
# 显示排除结果
Get-MpPreference | Select-Object -ExpandProperty ExclusionProcess

#配置防火墙排除规则

$exchProcesses = Get-Process | Where-Object { $_.Path -match "exchange" } | select-Object -Unique Path


foreach ($proc in $exchProcesses) {
    $path = $proc.Path
    if (-not [string]::IsNullOrEmpty($path)) {
        # 添加入站规则
        New-NetFirewallRule -DisplayName "Allow Exchange Inbound - $($path.Split('\')[-1])" `
            -Direction Inbound -Program $path -Action Allow
        # 添加出站规则
        New-NetFirewallRule -DisplayName "Allow Exchange Outbound - $($path.Split('\')[-1])" `
            -Direction Outbound -Program $path -Action Allow
    }
}

 

在 Exchange 服务器上运行 Windows 防病毒软件 | Microsoft Learn

防病毒软件导致群集服务出现问题 - Windows Server | Microsoft Learn

文章细节

文章编号:
3
添加日期:
2025-04-09 10:02:17

相关文章