|
#加载模块
$cred = Get-Credential "admin@test.com"
Import-Module MSOnline
Set-ExecutionPolicy remotesigned
Connect-MsolService -Credential $cred
#登录连入
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell/ -Credential $Cred -Authentication Basic -AllowRedirection
Import-PSSession $session
#设置搜索的时间段和发件人
$dateEnd = get-date
$dateStart = $dateEnd.AddHours(-1)
$sender="connx@aus.ddb.com"
#自定义时间,转换时区
Get-MessageTrace -StartDate $dateStart -EndDate $dateEnd -SenderAddress $sender| Select-Object @{name='time';e={[System.TimeZone]::CurrentTimeZone.ToLocalTime($_.received)}}, SenderAddress, RecipientAddress, Subject, Status, ToIP, FromIP, Size, MessageID, MessageTraceID | Out-GridView
|
|
|