Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 100
  • Last Modified:

Unread Messages in All User Inbox Exchange 2007 using Powershell

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
pbraden
Asked:
pbraden
  • 2
1 Solution
 
David Paris VicenteCommented:
Take a look here.

Let us know if helped.
0
 
mrmark75Commented:
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
 
pbradenAuthor Commented:
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
 
mrmark75Commented:
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

Independent Software Vendors: 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!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now