Solved

Unread Messages in All User Inbox Exchange 2007 using Powershell

Posted on 2014-09-15
4
59 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
ID: 40324209
Take a look here.

Let us know if helped.
0
 
LVL 3

Expert Comment

by:mrmark75
ID: 40324623
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
ID: 40325518
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
ID: 40325669
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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scam emails are a huge burden for many businesses. Spotting one is not always easy. Follow our tips to identify if an email you receive is a scam.
MS Outlook is a world-class email client application that is mainly used for e-communication globally.  In this article, we will discuss the basic idea about MS Outlook, its advanced features, and types of MS Outlook File formats.
In this video we show how to create an Address List 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 Organization >> Ad…
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…

863 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

25 Experts available now in Live!

Get 1:1 Help Now