Add-PSSnapin *exchange* if (Get-Item D:\scripts\mailsendreceive.html) { Remove-Item D:\scripts\mailsendreceive.html -Confirm:$false Write-Host -ForegroundColor Green "start checking tracking log,pls wait...." } else { Write-Host -ForegroundColor Green "start checking tracking log,pls wait...." } Write-Host -ForegroundColor Red "用戶名,接收郵件數,發送郵件數」 $emaild=Import-Csv D:\scripts\email.csv -Encoding Default $e=$emaild.email $send=$null $receive=$null $allitem=$null $cool=$null foreach ($i in $e) { $receive++ $send++ $receive=Get-TransportService | Get-MessageTrackingLog -Sender $i -ResultSize unlimited -Start "2016/12/15 12:00:00" -End "2017/01/15 12:00:00" -EventId Receive $send=Get-TransportService | Get-MessageTrackingLog -Sender $i -ResultSize unlimited -Start "2016/12/15 12:00:00" -End "2017/01/15 12:00:00" -EventId deliver $re=$receive.Count $se=$send.Count $allitem="$i,$re,$se" $allitem $cool = New-Object psobject $cool | Add-Member -MemberType NoteProperty -Name 用戶名 -Value $i $cool | Add-Member -MemberType NoteProperty -Name 接收郵件數 -Value $re $cool | Add-Member -MemberType NoteProperty -Name 發送郵件數 -Value $se $cool | Sort-Object 用戶名 -Descending | ConvertTo-Html | Out-File -Append D:\scripts\mailsendreceive.html } Write-Host "done!" -ForegroundColor Green
您也能夠關注下方微信公衆號獲取更多內容
html