我被卡住了,我試圖在一個人的郵箱中找到最舊的“EMAIL”,但我不知道還能嘗試什么。我想我需要在某處添加 ContainerClass -eq "IPF.Note",但我不確定在哪里。
以下腳本有效,但它會找到最舊的 ITEM,在我的情況下它是contact。我想分別查看每個容器(電子郵件、聊天、日歷、聯系人),但對于這個腳本,我只想知道最舊的電子郵件。
謝謝
Get-MailboxFolderStatistics -IncludeOldestAndNewestItems -Identity USERID |
Where OldestItemReceivedDate -ne $null |
Sort OldestItemReceivedDate |
Select -First 1 OldestItemReceivedDate
uj5u.com熱心網友回復:
假設這是出于合規性原因在 Exchange 服務器上搜索郵箱中的專案,您應該使用Search-Mailbox cmdlet - https://docs.microsoft.com/en-us/powershell/module/exchange/search-mailbox?視圖=交換-ps
要讓 Exchange Online 在郵箱中搜索專案,您應該使用New-ComplianceSearch cmdlet https://docs.microsoft.com/en-us/powershell/module/exchange/new-compliancesearch?view=exchange-ps
此網頁顯示如何按日期搜索 - New-ComplianceSearch:如何使用較新版本的 Search-Mailbox https://www.codetwo.com/admins-blog/new-compliancesearch-new-version-of-search-郵箱/
這個網頁有一個腳本來搜索郵箱,包括日期PowerShell – New-ComplianceSearch 腳本來遍歷所有郵箱,找到目標郵件,并將其洗掉- https://365basics.com/powershell-new-compliancesearch-script-to -go-through-all-mailboxes-find-a-target-message-and-remove-it/
使用您原來的方法,應該這樣做。假設您有適當的權限。
Get-MailboxFolderStatistics -ID <mailboxemailaddress> -IncludeOldestAndNewestItems | select Identity, Name, FolderPath, ItemsInFolder, FolderSize, OldestItemReceivedDate | Export-Csv C:\temp\Mailbox.csv -NoTypeInformation
uj5u.com熱心網友回復:
您可以按專案型別過濾您擁有的內容,但我會在獲取統計資訊后執行此操作,因此您只需查詢交換一次:
# Get the folder statistics for all folders
$stats = Get-MailboxFolderStatistics -IncludeOldestAndNewestItems -Identity $USERID
# Get the oldest email. Can re-use $stats for the other item types
$OldestEmail = $stats |
Where-Object {$_.OldestItemReceivedDate -and $_.ContainerClass -eq 'IPF.Note'} |
Sort-Object OldestItemReceivedDate |
Select-Object ContainerClass,OldestItemReceivedDate,FolderPath -First 1
# Outputs
ContainerClass OldestItemReceivedDate FolderPath
-------------- ---------------------- ----------
IPF.Note 2/8/2016 2:07:50 PM /Inbox
您是正確的,郵箱檔案夾統計命令默認不搜索可恢復的專案。除非您指定,否則它也不會搜索郵箱存檔-Archive。如果您需要這些,則必須進行其他搜索:
# Get recoverable items:
Get-MailboxFolderStatistics -Identity $USERID -FolderScope 'RecoverableItems' -IncludeOldestAndNewestItems |
Where-Object OldestItemReceivedDate |
Sort-Object OldestItemReceivedDate |
Select-Object ContainerClass,OldestItemReceivedDate,FolderPath -First 1
# Note that deleted item containers do not have an item type!
ContainerClass OldestItemReceivedDate FolderPath
-------------- ---------------------- ----------
2/5/2016 3:41:33 PM /Deletions
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/372236.html
