搜鞥都哦 发表于 2018-9-2 10:04:49

Powershell 查询 Office 365 邮件

#加载模块  

  
$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={::CurrentTimeZone.ToLocalTime($_.received)}}, SenderAddress, RecipientAddress, Subject, Status, ToIP, FromIP, Size, MessageID, MessageTraceID | Out-GridView


页: [1]
查看完整版本: Powershell 查询 Office 365 邮件