[玩转系统] 如何确定哪些活动规则影响电子邮件附件
作者:精品下载站 日期:2024-12-14 06:46:29 浏览:16 分类:玩电脑
如何确定哪些活动规则影响电子邮件附件
MS-220 Exchange Online 故障排除考试的要求之一是您应该能够确定哪些活动邮件流规则会影响电子邮件附件。如果您是 Exchange 管理员并且有用户向您报告他们没有收到来自发件人的预期邮件附件,则此功能非常有用。
在本教程中,我将向您展示如何使用 Exchange 管理中心和 PowerShell 来查找影响附件的活动邮件流规则。
先决条件
要完成此任务,您必须是 Microsoft 365 中 Exchange 管理员组或全局管理员组的成员。
此外,为了运行本教程中必要的脚本,您还应该安装 Exchange Online PowerShell 模块。请参阅我的有关如何安装 Exchange Online PowerShell 模块的教程。
使用 Exchange 管理中心确定哪些活动规则会影响电子邮件附件
要使用 Exchange 管理中心 Web UI 查找哪些活动规则影响邮件附件,请按照以下步骤操作。
1. 首先登录 Exchange 管理中心:https://admin.exchange.microsoft.com/
2. 从左侧菜单中,展开邮件流并选择规则。
3. 使用左上角的搜索框并搜索单词“附件”。这还将搜索包括规则条件的规则描述。
4. 您现在只会看到名称或描述中包含“附件”一词的搜索结果。然后,您可以手动单击每个规则来确定条件和操作。
确定哪些活动规则影响电子邮件附件 使用 PowerShell
要使用 PowerShell 生成影响电子邮件附件的规则条件的报告,您可以使用以下脚本。该脚本可能有点过度设计,但它会将“数组列表”类型条件转换为字符串,然后将整个变量转换为字符串,然后将数据提取到可以搜索或导出的标题列中。
您需要手动定义的唯一参数是 $rulename 变量,我在其中使用下面的示例作为“阻止某些消息”。
#Connect to Exchange Online
Connect-ExchangeOnline
#Store exact rule name
$rulename = "Block certain messages"
#Store rule parameters which affect attachments
$attachmentrules = get-transportrule "$rulename" | Select *attachment*
#Convert array objects to string
$string1 = $attachmentrules.AttachmentExtensionMatchesWords | out-string
$attachmentrules.AttachmentExtensionMatchesWords = $string1
$string2 = $attachmentrules.AttachmentNameMatchesPatterns | out-string
$attachmentrules.AttachmentNameMatchesPatterns = $string2
$string3 = $attachmentrules.AttachmentPropertyContainsWords | out-string
$attachmentrules.AttachmentPropertyContainsWords = $string3
$string4 = $attachmentrules.AttachmentContainsWords | out-string
$attachmentrules.AttachmentContainsWords = $string4
$string5 = $attachmentrules.AttachmentMatchesPatterns | out-string
$attachmentrules.AttachmentMatchesPatterns = $string5
$string6 = $attachmentrules.ExceptIfAttachmentNameMatchesPatterns | out-string
$attachmentrules.ExceptIfAttachmentNameMatchesPatterns = $string6
$string7 = $attachmentrules.ExceptIfAttachmentExtensionMatchesWords | out-string
$attachmentrules.ExceptIfAttachmentExtensionMatchesWords = $string7
$string8 = $attachmentrules.ExceptIfAttachmentPropertyContainsWords | out-string
$attachmentrules.ExceptIfAttachmentPropertyContainsWords = $string8
$string9 = $attachmentrules.ExceptIfAttachmentSizeOver | out-string
$attachmentrules.ExceptIfAttachmentSizeOver = $string9
$string10 = $attachmentrules.ExceptIfAttachmentContainsWords | out-string
$attachmentrules.ExceptIfAttachmentContainsWords = $string10
$string11 = $attachmentrules.ExceptIfAttachmentMatchesPatterns | out-string
$attachmentrules.ExceptIfAttachmentMatchesPatterns = $string11
$string = "$attachmentrules"
#Create Report object
$Report = [System.Collections.Generic.List[Object]]::new()
#Define regex parameters
$reg = [RegEx]"(\w+)=(\w*)"
#Create report to review
$table=@()
$table = $reg.Matches($string) | ForEach-Object {
$rhs = if($_.Groups[2].Value){
$_.Groups[2].Value
}else{
"N/A"
}
$obj = [PSCustomObject][ordered]@{
"TYPE" = $_.Groups[1].Value
"VALUE" = $rhs
}
$Report.Add($obj)
} | Format-Table
#Display report in session
$report
#Export report to CSV
$report | export-csv C:\temp\MailRuleAttachmentInfo.csv -NoTypeInformation
我还对上述内容进行了扩展,下面的脚本将使用 PowerShell 生成有关 Exchange Online 中所有传输规则的报告。在这种情况下,您不需要指定任何变量,因为它将循环遍历每个规则并生成输出。
#Connect to Exchange Online
Connect-ExchangeOnline
#Create Report object
$Report = [System.Collections.Generic.List[Object]]::new()
#Store all transport rules
$alltransportrules = get-transportrule
#Loop through all transport rules
ForEach ($Rule in $alltransportrules){
#Store rule parameters which affect attachments
$attachmentrules = get-transportrule $rule.name | Select *attachment*
#Convert array objects to string
$string1 = $attachmentrules.AttachmentExtensionMatchesWords | out-string
$attachmentrules.AttachmentExtensionMatchesWords = $string1
$string2 = $attachmentrules.AttachmentNameMatchesPatterns | out-string
$attachmentrules.AttachmentNameMatchesPatterns = $string2
$string3 = $attachmentrules.AttachmentPropertyContainsWords | out-string
$attachmentrules.AttachmentPropertyContainsWords = $string3
$string4 = $attachmentrules.AttachmentContainsWords | out-string
$attachmentrules.AttachmentContainsWords = $string4
$string5 = $attachmentrules.AttachmentMatchesPatterns | out-string
$attachmentrules.AttachmentMatchesPatterns = $string5
$string6 = $attachmentrules.ExceptIfAttachmentNameMatchesPatterns | out-string
$attachmentrules.ExceptIfAttachmentNameMatchesPatterns = $string6
$string7 = $attachmentrules.ExceptIfAttachmentExtensionMatchesWords | out-string
$attachmentrules.ExceptIfAttachmentExtensionMatchesWords = $string7
$string8 = $attachmentrules.ExceptIfAttachmentPropertyContainsWords | out-string
$attachmentrules.ExceptIfAttachmentPropertyContainsWords = $string8
$string9 = $attachmentrules.ExceptIfAttachmentSizeOver | out-string
$attachmentrules.ExceptIfAttachmentSizeOver = $string9
$string10 = $attachmentrules.ExceptIfAttachmentContainsWords | out-string
$attachmentrules.ExceptIfAttachmentContainsWords = $string10
$string11 = $attachmentrules.ExceptIfAttachmentMatchesPatterns | out-string
$attachmentrules.ExceptIfAttachmentMatchesPatterns = $string11
$string = "$attachmentrules"
#Define regex parameters
$reg = [RegEx]"(\w+)=(\w*)"
#Create report to review
$table=@()
$table = $reg.Matches($string) | ForEach-Object {
$rhs = if($_.Groups[2].Value){
$_.Groups[2].Value
}else{
"N/A"
}
$obj = [PSCustomObject][ordered]@{
"RULE NAME" = $Rule.name
"TYPE" = $_.Groups[1].Value
"VALUE" = $rhs
}
$Report.Add($obj)
} | Format-Table
}
#Display report in session
$report
#Export report to csv
$report | export-csv C:\temp\AllMailRuleAttachmentInfo.csv -NoTypeInformation
如果你有很多规则,输出将会相当大。您应该使用 Excel 中的“筛选”功能来适当减少结果。
- 导航到 C:\temp 并打开 CSV 文件。
2. 调整列的宽度,然后选择值列,单击顶部的数据选项卡,然后单击过滤器。
3. 单击值旁边的下拉箭头并取消选中“N/A”和“False”。
4. 现在您只剩下有意义的信息。
禁用影响规则
确定哪些规则影响电子邮件附件后,您可以禁用该规则,同时进一步解决问题的根本原因。
通过 Exchange 管理中心禁用规则
1. 登录 Exchange 管理中心后,展开邮件流并选择规则。
2. 在列表中找到您想要禁用的规则,然后单击规则名称。
3. 单击启用或禁用规则滑块以禁用规则。
使用 PowerShell 禁用规则
首先,要查看所有启用的规则,您可以运行以下命令:
Get-TransportRule | Where-Object {$_.State -eq "Enabled"}
然后,您可以使用以下脚本来定位特定规则,确保将规则标识更改为与目标规则匹配的规则名称。
$Rule = Get-TransportRule -Identity "Block .exe attachments"
If ($rule.state -eq "Enabled") {
Disable-TransportRule -Identity $Rule.Name -confirm:$false
Write-host $rule.name ": has been disabled" -ForegroundColor black -BackgroundColor green
} Else {
Write-host $rule.name ": is already disabled" -ForegroundColor black -BackgroundColor yellow
}
您还可以在我的 GitHub 上查看上述所有脚本。
猜你还喜欢
- 03-30 [玩转系统] 如何用批处理实现关机,注销,重启和锁定计算机
- 02-14 [系统故障] Win10下报错:该文件没有与之关联的应用来执行该操作
- 01-07 [系统问题] Win10--解决锁屏后会断网的问题
- 01-02 [系统技巧] Windows系统如何关闭防火墙保姆式教程,超详细
- 12-15 [玩转系统] 如何在 Windows 10 和 11 上允许多个 RDP 会话
- 12-15 [玩转系统] 查找 Exchange/Microsoft 365 中不活动(未使用)的通讯组列表
- 12-15 [玩转系统] 如何在 Windows 上安装远程服务器管理工具 (RSAT)
- 12-15 [玩转系统] 如何在 Windows 上重置组策略设置
- 12-15 [玩转系统] 如何获取计算机上的本地管理员列表?
- 12-15 [玩转系统] 在 Visual Studio Code 中连接到 MS SQL Server 数据库
- 12-15 [玩转系统] 如何降级 Windows Server 版本或许可证
- 12-15 [玩转系统] 如何允许非管理员用户在 Windows 中启动/停止服务
取消回复欢迎 你 发表评论:
- 精品推荐!
-
- 最新文章
- 热门文章
- 热评文章
[影视] 黑道中人 Alto Knights(2025)剧情 犯罪 历史 电影
[古装剧] [七侠五义][全75集][WEB-MP4/76G][国语无字][1080P][焦恩俊经典]
[实用软件] 虚拟手机号 电话 验证码 注册
[电视剧] 安眠书店/你 第五季 You Season 5 (2025) 【全10集】
[电视剧] 棋士(2025) 4K 1080P【全22集】悬疑 犯罪 王宝强 陈明昊
[软件合集] 25年6月5日 精选软件22个
[软件合集] 25年6月4日 精选软件36个
[短剧] 2025年06月04日 精选+付费短剧推荐33部
[短剧] 2025年06月03日 精选+付费短剧推荐25部
[软件合集] 25年6月3日 精选软件44个
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电视剧] 欢乐颂.5部全 (2016-2024)
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[影视] 【稀有资源】香港老片 艺坛照妖镜之96应召名册 (1996)
[剧集] 神经风云(2023)(完结).4K
[剧集] [BT] [TVB] [黑夜彩虹(2003)] [全21集] [粤语中字] [TV-RMVB]
[实用软件] 虚拟手机号 电话 验证码 注册
[资源] B站充电视频合集,包含多位重量级up主,全是大佬真金白银买来的~【99GB】
[影视] 内地绝版高清录像带 [mpg]
[书籍] 古今奇书禁书三教九流资料大合集 猎奇必备珍藏资源PDF版 1.14G
[电视剧] [突围] [45集全] [WEB-MP4/每集1.5GB] [国语/内嵌中文字幕] [4K-2160P] [无水印]
[剧集] [央视][笑傲江湖][2001][DVD-RMVB][高清][40集全]李亚鹏、许晴、苗乙乙
[电影] 美国队长4 4K原盘REMUX 杜比视界 内封简繁英双语字幕 49G
[电影] 死神来了(1-6)大合集!
[软件合集] 25年05月13日 精选软件16个
[精品软件] 25年05月15日 精选软件18个
[绝版资源] 南与北 第1-2季 合集 North and South (1985) /美国/豆瓣: 8.8[1080P][中文字幕]
[软件] 25年05月14日 精选软件57个
[短剧] 2025年05月14日 精选+付费短剧推荐39部
[短剧] 2025年05月15日 精选+付费短剧推荐36部
- 最新评论
-
- 热门tag