Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Unread Messages in All User Inbox Exchange 2007 using Powershell

Posted on 2014-09-15
4
Medium Priority
?
99 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 2000 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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

New style of hardware planning for Microsoft Exchange server.
The core idea of this article is to make you acquainted with the best way in which you can export Exchange mailbox to PST format.
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Suggested Courses

670 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