如何使用Powershell 对office365的邮件进行查询追踪
1. 首先链接到Exchange Online 管理上面
$UserCredential = Get-Credential $Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://partner.outlook.cn/PowerShell -Credential $UserCredential -Authentication Basic -AllowRedirection Import-PSSession $Session
2. 查询邮件追踪,导出UTF-8到csv文件中
$dateEnd = get-date $dateStart = $dateEnd.AddHours(-8) #目前时间之前的8个小时之内 $recipient="[email protected]" #导出收件人是[email protected]的用户 #自定义时间,转换时区 Get-MessageTrace -StartDate $dateStart -EndDate $dateEnd -RecipientAddress $recipient | Select-Object @{name=‘time‘;e={[System.TimeZone]::CurrentTimeZone.ToLocalTime($_.received)}}, SenderAddress, RecipientAddress, Subject, Status, ToIP, FromIP, Size, MessageID, MessageTraceID |export-csv -encoding utf8 d:\Only.csv
时间: 2024-10-14 18:50:54