TigerBlood
asked on
Can Powershell run a script to output the overall oldest item received/ overall newest item received in an Exchange 2010 mailbox?
I am trying to create a powershell script in Exchange 2010 that outputs the overall oldest item received and overall newest item received for each individual mailbox. In addition, the script should output the username, the number of items total in the entire mailbox, and the retention policy that is set for that mailbox.
I have the script below, which outputs the oldest/ newest items received but it outputs for each folder and subfolder (i.e. inbox, sent items, any manually created mail folders, etc.). Sure, I could compare manually the oldest/ newest items received for each folder but this would be very time consuming as we have a large amount of mailboxes and I am wondering if this could be done in powershell. the output should be to a CSV file.
Thanks in advance for your help!
$temp="C:\mbs_temp.csv"
$outputfile="C:\mbs_output .csv"
foreach($mbx in Get-Mailbox){
Get-MailboxFolderStatistic s -includeoldestandnewestite ms $mbx.identity | select @{n="DisplayName";e={$mbx. displayNam e}},Folder Path,Items InFolder,F olderSize, OldestItem receivedDa te,NewestI temreceive dDate | Export-Csv $temp
$readtemp=get-Content $temp
$readtemp | Out-File $outputfile -Append -NoClobber
Remove-Item $temp
}
I have the script below, which outputs the oldest/ newest items received but it outputs for each folder and subfolder (i.e. inbox, sent items, any manually created mail folders, etc.). Sure, I could compare manually the oldest/ newest items received for each folder but this would be very time consuming as we have a large amount of mailboxes and I am wondering if this could be done in powershell. the output should be to a CSV file.
Thanks in advance for your help!
$temp="C:\mbs_temp.csv"
$outputfile="C:\mbs_output
foreach($mbx in Get-Mailbox){
Get-MailboxFolderStatistic
$readtemp=get-Content $temp
$readtemp | Out-File $outputfile -Append -NoClobber
Remove-Item $temp
}
ASKER
Very nice script! this pulled the info and exported to CSV. However, I have only been at this firm since Oct 2010, but it tells me the oldest item I have is in May 2010. How is this possible?
Also, the newest items seem to be off by 4hrs. They report a time that is 4hrs into the future. I researched this a little and ran the get-date -f zz in my powerShell and it returned -04, which I understand to be my timezone offset. I see there is a ToLocalTime command to address this specific issue and I have tried to add this to your script but I am receiving all kinds of errors. Ah... powershell scripting is really not my strong point! :) Would you know how to add this? Thanks!
Also, the newest items seem to be off by 4hrs. They report a time that is 4hrs into the future. I researched this a little and ran the get-date -f zz in my powerShell and it returned -04, which I understand to be my timezone offset. I see there is a ToLocalTime command to address this specific issue and I have tried to add this to your script but I am receiving all kinds of errors. Ah... powershell scripting is really not my strong point! :) Would you know how to add this? Thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Fantastic solution. Very quick response.
Im wondering how you can tweak this script to also include the online archive mailbox and the mailbox in this query, perhaps a -archive somewhere, but not sure where, i'd want the results to include both. Thanks
Open in new window