Skip to content

Instantly share code, notes, and snippets.

@gioxx
Last active December 5, 2018 10:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gioxx/7b7348c81ff33fe8d23fa7a59180432e to your computer and use it in GitHub Desktop.
Save gioxx/7b7348c81ff33fe8d23fa7a59180432e to your computer and use it in GitHub Desktop.
Restituisce la data (e la cartella in cui è contenuto) il messaggio più vecchio mai ricevuto all'interno di una casella di posta elettronica Office 365, vedi https://wp.me/pdQ5q-9W3
<# O365 PShell Snippet: Get oldest message in a Mailbox
Autore (ver.-mod.): GSolone (0.1 ult.mod. 21/11/18)
Utilizzo: .\OldestMail.ps1 user@contoso.com
Info: https://gioxx.org/tag/o365-powershell
#>
# Verifica parametri da prompt
Param(
[Parameter(Position=0, Mandatory=$true, ValueFromPipeline=$true)]
[string] $SourceMailbox
)
Get-MailboxFolderStatistics -IncludeOldestAndNewestItems -Identity $SourceMailbox |
Where OldestItemReceivedDate -ne $null |
Sort OldestItemReceivedDate |
Select -First 1 OldestItemReceivedDate,FolderPath
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment