Looking for PS script to display most recently received mail
I'm trying to cobble a PS script together to pull information on a single mailbox. I'd like to check the status hourly of a mailbox to make sure it's receiving mail. Is there a way to pull the date / time of the last recieved mail?
May 23rd, 2008 1:26am

Hi Sandy, This should give you date/time of last received items for all folders in mailbox. Get-MailboxFolderStatistics <UserID> -IncludeOldestAndNewestItems | Select Name, NewestItemReceivedDate Toverify just Inbox,here is the command... Get-MailboxFolderStatistics <UserID> -IncludeOldestAndNewestItems | Where-Object {$_.Name -eq "Inbox" }| Select Name, NewestItemReceivedDate Hope this helps..!!!
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2008 6:19am

Thanks very much! This should do the job!
May 23rd, 2008 5:16pm

I found that the NewestItemReceiveDate returns UTC time. Any idea how to convert it back to local time?
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2008 6:55pm

Save the codeand give the name Get-NewestItemTime.ps1 and run like below command ./Get-NewestItemTime "User Name" Get-NewestItemTime.ps1 param( [string] $user = $(throw "Give me the user name")) $ni = Get-MailboxFolderStatistics $user -IncludeOldestAndNewestItems | Where-Object {$_.Name -eq "Inbox" } $ni.NewestItemReceivedDate.ToLocalTime() Hope this helps...!!!
May 23rd, 2008 8:03pm

Thanks! You are an absolute genius! It's works perfectly! I did have an issue with including the -IncludeOldestAdnNewestItems In the code...it threw an error that said a parameter could not be found that matches parameter name 'IncludeOldestAndNewestItems' I removed that paramter and it worked perfect however!
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2008 8:33pm

Glad to hear that it worked!!! I tested in SP1 with IncludeOldestAndNewestItems switch without error. Are you running with SP1?
May 23rd, 2008 8:41pm

No, I'm sure that's why. But to me this is still a quantum leap with what I have working, thanks to your help! I found a .ps1 script thatwill send smtp email based on a date/time comparison I need to add to the script. Our management want's to know if a certain mailbox is not getting email in over 1 hour.
Free Windows Admin Tool Kit Click here and download it now
May 23rd, 2008 8:45pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics