You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

能否用PowerShell获取Outlook连接状态活动表?排查365基础认证设备

定位使用基础认证连接Office 365的设备方案

下面提供几种程序化获取Outlook连接认证类型的方法,替代你之前尝试的MAPI命名空间方法:

1. 利用Outlook COM对象读取账户扩展属性

通过访问Outlook账户的MAPI扩展属性,可以直接获取认证类型信息,PowerShell代码示例:

$Outlook = New-Object -ComObject Outlook.Application
$Session = $Outlook.Session
foreach ($account in $Session.Accounts) {
    # 获取Authn类型对应的扩展属性(0x66080003)
    try {
        $authnProp = $account.PropertyAccessor.GetProperties("http://schemas.microsoft.com/mapi/proptag/0x66080003")
        $authnType = if ($authnProp -eq 0) { "基础认证" } elseif ($authnProp -eq 1) { "现代认证" } else { "未知" }
        Write-Host "账户: $($account.DisplayName) - 认证类型: $authnType"
    } catch {
        Write-Warning "无法读取账户 $($account.DisplayName) 的认证属性: $_"
    }
}

注:0x66080003属性值对应关系:0=基础认证,1=现代认证,不同Outlook版本可能略有差异,需测试验证。

2. 读取Outlook连接日志文件

Outlook会自动生成连接日志,可直接解析日志中的Authn字段判断认证类型,PowerShell代码示例:

$logDir = "$env:USERPROFILE\AppData\Local\Microsoft\Outlook\Connection Logs"
if (Test-Path $logDir) {
    Get-ChildItem $logDir -Filter *.log | ForEach-Object {
        $logContent = Get-Content $_.FullName -Raw
        if ($logContent -match 'Authn:\s*(.*)') {
            Write-Host "设备当前连接认证类型: $($matches[1])"
            # 如需筛选基础认证,可添加判断:if ($matches[1] -eq 'Basic') { ... }
        }
    }
} else {
    Write-Warning "未找到Outlook连接日志目录"
}

3. 查询Windows事件日志

Outlook的Operational日志会记录连接认证事件,通过事件ID筛选获取信息,PowerShell代码示例:

try {
    $events = Get-WinEvent -LogName "Microsoft-Windows-Outlook/Operational" -FilterXPath "*[System[EventID=26]]" -MaxEvents 10
    foreach ($event in $events) {
        $eventXml = [xml]$event.ToXml()
        $authnType = $eventXml.Event.EventData.Data | Where-Object { $_.Name -eq "AuthnType" } | Select-Object -ExpandProperty "#text"
        Write-Host "最近连接认证类型: $authnType"
    }
} catch {
    Write-Warning "无法读取Outlook事件日志: $_"
}

注:事件ID 26对应Outlook的连接状态更新事件,AuthnType字段值为Basic时是基础认证,Modern为现代认证。

内容的提问来源于stack exchange,提问作者Matt

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.18 13:50:46