我想寫的Exchange PowerShell腳本,將找到的郵件特定郵箱已經1個月的時限內收到的數量和電子郵件的對象總計特定個人。到目前爲止,我已經得到了:交易所自動化腳本
$date = Get-Date -Format MM/dd/yyyy
$time = Get-Date -Format HH:mm:ss
$previousMonth =
PS C:\> Get-MessageTrackingLog -Recipients:mailbox1.org -start "02/01/2017 00:00:00" -end "$date $time" -EventId "Receive" -ResultSize unlimited | Measure-Object
PS C:\> Get-MessageTrackingLog -Recipients:mailbox2.org -start "02/01/2017 00:00:00" -end "$date $time" -EventId "Receive" -ResultSize unlimited | Measure-Object
PS C:\> Get-MessageTrackingLog -Recipients:mailbox3.org -start "02/01/2017 00:00:00" -end "$date $time" -EventId "Receive" -ResultSize unlimited | Measure-Object
PS C:\> Get-MessageTrackingLog -Recipients:mailbox4.org -start "02/01/2017 00:00:00" -end "$date $time" -EventId "Receive" -ResultSize unlimited | Measure-Object
ps c:\> Send-MailMessage -SmtpServer "server" -To "recipient email<recipient email>" -From "Monthly Mailbox Totals <email address>" -Subject "Monthly Mailbox Item Count" -Body ""
什麼我遇到的麻煩是這樣的:我不能完全弄清楚如何計算日期範圍-start投入,得到前一個月的1號從目前的日期和時間,其次,我堅持如何從格式化到發送的電子郵件的正文總和。如果有幫助,我希望每個月的第一個腳本都能運行。
將不勝感激任何提示預先感謝您。
我在這裏看到2-3獨立的問題。你應該儘量限制自己只有一個。您可以使用日期方法來獲取過去的日期,並保留當前的格式邏輯。您甚至沒有保存跟蹤日誌請求的結果。你還問如何自動化這個? – Matt