如何通过PowerShell自动化配置Outlook信任中心纯文本读信设置

问题根因
手动创建readasplain注册表项后修改不生效,核心原因有两点:
- 注册表项未放置到Outlook对应版本的正确配置路径下,Outlook不会加载Mail根目录下的零散配置值
- Outlook启动时会优先加载绑定用户配置文件的本地缓存,仅在缓存标记失效时才会重新读取注册表值,直接修改注册表不会主动触发缓存刷新,仅重启系统无法触发该逻辑。
注册表项规则说明
Outlook「以纯文本格式读取所有标准邮件」功能对应的注册表配置规则如下:
- 正确路径格式:
HKCU:\Software\Microsoft\Office\<Office主版本号>\Outlook\Options\Mail
常见版本对应号:- Outlook 365/2021/2019/2016:
16.0 - Outlook 2013:
15.0 - Outlook 2010:
14.0
- Outlook 365/2021/2019/2016:
- 需配置的键值:
ReadAsPlain(REG_DWORD类型):值为1时启用纯文本读取标准邮件,值为0时关闭ReadAsPlainAllSigned(REG_DWORD类型):值为1时对签名邮件同样生效,避免配置被安全逻辑回滚
PowerShell自动化配置脚本
执行前请保存Outlook内未完成的编辑内容,脚本会自动终止Outlook进程完成配置
# 终止所有运行中的Outlook进程 Get-Process outlook -ErrorAction SilentlyContinue | Stop-Process -Force # 自动匹配当前设备安装的Outlook版本配置路径 $validVersionRoots = Get-ChildItem "HKCU:\Software\Microsoft\Office\" -ErrorAction SilentlyContinue | Where-Object { $_.PSIsContainer -and $_.Name -match '\\(\d+\.0)$' } | Sort-Object Name -Descending $targetConfigPath = $null foreach ($versionRoot in $validVersionRoots) { $testMailPath = Join-Path $versionRoot.PSPath "Outlook\Options\Mail" if (Test-Path $testMailPath) { $targetConfigPath = $testMailPath break } } # 未检测到现成配置路径时,默认按当前主流版本16.0创建路径 if (-not $targetConfigPath) { $targetConfigPath = "HKCU:\Software\Microsoft\Office\16.0\Outlook\Options\Mail" New-Item -Path $targetConfigPath -Force | Out-Null } # 写入功能配置 Set-ItemProperty -Path $targetConfigPath -Name "ReadAsPlain" -Value 1 -Type DWord -Force Set-ItemProperty -Path $targetConfigPath -Name "ReadAsPlainAllSigned" -Value 1 -Type DWord -Force # 清理配置缓存,强制Outlook下次启动读取新的注册表配置 $cacheItemPath = Join-Path $targetConfigPath "CachedConfig" if (Test-Path $cacheItemPath) { Remove-Item -Path $cacheItemPath -Recurse -Force } Write-Host "配置写入完成,启动Outlook即可生效"
注意事项
- 配置完成后无需重启系统,直接启动Outlook即可在「文件>选项>信任中心>信任中心设置>电子邮件安全」路径下看到对应选项已自动勾选
- 域环境设备请先确认域组策略未配置强制锁定Outlook邮件读取格式,否则组策略定期刷新时会覆盖脚本写入的注册表值
内容的提问来源于stack exchange,提问作者DevopsDevelop
相关产品推荐
相关产品推荐

