Solved

Unread Messages in All User Inbox Exchange 2007 using Powershell

Posted on 2014-09-15
4
85 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Utilizing an array to gracefully append to a list of EmailAddresses
This article explains in simple steps how to renew expiring Exchange Server Internal Transport Certificate.
In this video we show how to create an Accepted Domain 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 Mail Flow >> Ac…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

732 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