Solved

Unread Messages in All User Inbox Exchange 2007 using Powershell

Posted on 2014-09-15
4
55 Views
Last Modified: 2015-04-09
I need to get a count of all read and unread messages in all the users mailboxes in on our Exchange 2007 Server.

I know how to get a list of inbox size and number of items.  I just need to find out how many are unread.

Does anyone have a powershell script to do this?
0
Comment
Question by:pbraden
  • 2
4 Comments
 
LVL 12

Expert Comment

by:David Paris Vicente
Comment Utility
Take a look here.

Let us know if helped.
0
 
LVL 3

Expert Comment

by:mrmark75
Comment Utility
Create a folder on your exchange server c:\temp

download this and extract it to c:\temp.

now open notepad and copy this into it

[void][Reflection.Assembly]::LoadFile("C:\temp\EWSUtil.dll")
$fname = "c:\temp\unreadreport.csv"

$mbcombCollection = @()

get-mailbox | foreach-object{
      $mbcomb = "" | select DisplayName,EmailAddress,Unread
      $mbcomb.DisplayName = $_.DisplayName.ToString()
      $mbcomb.EmailAddress = $_.WindowsEmailAddress.ToString()
      $mbMailboxEmail = $_.WindowsEmailAddress.ToString()
      "Mailbox : " + $mbMailboxEmail
      $ewc = new-object EWSUtil.EWSConnection($mbMailboxEmail,$false, $null,$null,$null,$null)
      $dTypeFld = new-object EWSUtil.EWS.DistinguishedFolderIdType
      $dTypeFld.Id = [EWSUtil.EWS.DistinguishedFolderIdNameType]::inbox

      $mbMailbox = new-object EWSUtil.EWS.EmailAddressType
      $mbMailbox.EmailAddress = $mbMailboxEmail
      $dTypeFld.Mailbox = $mbMailbox

      $fldarry = new-object EWSUtil.EWS.BaseFolderIdType[] 1
      $fldarry[0] = $dTypeFld

      $fldList = $ewc.GetFolder($fldarry)
      [EWSUtil.EWS.FolderType]$pfld = [EWSUtil.EWS.FolderType]$fldList[0];
        $mbcomb.Unread = $pfld.UnreadCount
      $mbcombCollection += $mbcomb
}

$mbcombCollection | export-csv -noTypeInformation $fname



Save file it to c:\temp  call it userunreadmail.ps1

Now open you exchange management shell

do a cd\
then cd temp
then type    Set-ExecutionPolicy Unrestricted
you will have to accept it with a Y
then type    userunreadmail.ps1
type R
it will run and create a report in the c:\temp dir called unreadreport.csv you can import that to excel and have a nice file. If you dont have many users you can remove:  | export-csv -noTypeInformation $fname  and you will see the output in the shell.   That should get you what you are looking for.
0
 

Author Comment

by:pbraden
Comment Utility
When I try to type userunreadmail.ps1 I get an error message "The term "userunreadmail.ps1" is not recognized as the name of a cmdlet, function, or script file, or operable program.

if I type .\userunreadmail.ps1 to run the script I get an error message on all the users saying Excetion call "GetFoler" with "2:" arguments: The request failed with HTTP status 401: Unauthorized.:"
0
 
LVL 3

Accepted Solution

by:
mrmark75 earned 500 total points
Comment Utility
Are you logged in as an administrator? You need to be logged in with an account that has mailboxpermission. Make sure you run the shell with administrative privileges.
0

Featured Post

Do email signature updates give you a headache?

Do you feel like you are constantly making changes to email signatures? Are the images not formatting how you want them to? Want high-quality HTML signatures on all devices, including on mobiles and Macs? Then, let Exclaimer solve all your email signature problems today.

Join & Write a Comment

Follow this checklist to learn more about the 15 things you should never include in an email signature from personal quotes, animated gifs and out-of-date marketing content.
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
To show how to generate a certificate request in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.:  First we need to log into the Exchange Admin Center. Navigate to the Servers >> Certificates…
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

6 Experts available now in Live!

Get 1:1 Help Now