none
Excange 2010 Delievery Report Powershell

    Question

  • Hey I there a way to export the delievery report in powershell

    I want to be able to make a report of who has read an email with a specific subject for example

    I know you can do this in ECP but i want to automate this so powershell would be best

    Wednesday, December 21, 2011 6:16 PM

All replies

  • Hi
        Maybe you can try this :
       Get-ExchangeServer | where {$_.IsHubTransportServer -eq “true”} | Get-MessageTrackingLog -Recipients:undergraduatestudents@domain.edu -EventId “RECEIVE” | select TimeStamp,Sender,{$_.recipients},MessageSubject | Export-Csv C:\undergraduatestudents.csv
       You can know function of
      
    http://technet.microsoft.com/en-us/library/aa997573.aspx
      
    It just offer event id “BadMail, Defer Deliver, DSN, Expand, Fail, PoisonMessage, Receive, Redirect, Resolve, Send, Submit, and Transfer” No “read


    Terence Yu

    TechNet Community Support

    Friday, December 23, 2011 12:43 AM
    Moderator
  • thanks this wont tell if the user opened it though just that it was delivered. there's got to be a way to export searching on the read marker its clearly in ecp. pretty frustrating that its no in powershell
    test
    Wednesday, December 28, 2011 9:31 PM
  • thanks this wont tell if the user opened it though just that it was delivered. there's got to be a way to export searching on the read marker its clearly in ecp. pretty frustrating that its no in powershell
    test

    You would do this using Exchange Web Services, via the IsRead property:

    http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.emailmessage.isread(v=exchg.80).aspx

     

    This CAN be done via PowerShell, but you have to use EWS.

    Wednesday, December 28, 2011 9:54 PM
  • thanks this wont tell if the user opened it though just that it was delivered. there's got to be a way to export searching on the read marker its clearly in ecp. pretty frustrating that its no in powershell
    test

    You would do this using Exchange Web Services, via the IsRead property:

    http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.emailmessage.isread(v=exchg.80).aspx

     

    This CAN be done via PowerShell, but you have to use EWS.

    Thanks, but a bit confused how to search for email subject in EWS then filter in the IsRead property. Do you know have a short example?

     

     


    test
    Thursday, December 29, 2011 3:52 PM
  • Here is a powerhshell script that will search a users mailbox from yesterday, and list the emails that have a subject containing the word "test" and are marked as unread.

     

    This is great, 

    This guy pointed me in the right direction.

    http://gsexdev.blogspot.com/2010/08/using-exchange-search-and-aqs-with-ews.html 

     

     

     

     

    #Searchs Emails from Yeserday with Subject and If Read or unread
    
    
    $MailboxName = $args[0]
    
    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
    
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind
    
    $service.AutodiscoverUrl($aceuser.mail.ToString())
    
    
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    
    
    $iv = new-object Microsoft.Exchange.WebServices.Data.ItemView(2000)
    $fiItems = $service.FindItems($folderid, "Received:yesterday AND subject:Test NOT is:read", $iv)
    foreach ($Item in $fiItems.Items)
    {
       $Item.Subject
      
    }
    



    test
    Friday, December 30, 2011 1:53 PM
  • Here is a powerhshell script that will search a users mailbox from yesterday, and list the emails that have a subject containing the word "test" and are marked as unread.

     

    This is great, 

    This guy pointed me in the right direction.

    http://gsexdev.blogspot.com/2010/08/using-exchange-search-and-aqs-with-ews.html 

     

     

     

     

     

    #Searchs Emails from Yeserday with Subject and If Read or unread
    
    
    $MailboxName = $args[0]
    
    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
    
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind
    
    $service.AutodiscoverUrl($aceuser.mail.ToString())
    
    
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    
    
    $iv = new-object Microsoft.Exchange.WebServices.Data.ItemView(2000)
    $fiItems = $service.FindItems($folderid, "Received:yesterday AND subject:Test NOT is:read", $iv)
    foreach ($Item in $fiItems.Items)
    {
       $Item.Subject
      
    }
    


     


    test

    does anyone know of a way that i can do this for all mailboxes in my enviroment?

     


    test
    Tuesday, January 03, 2012 6:58 PM
  • Are you sure you want to do it for all mailboxes? 

     If it's a specific message you want to track, you can get the list of the mailboxes that specific message was delivered to from the message tracking logs, and then use a foreach loop to go through the EWS script for each of those mailboxes.

    By narrowing it down to  a specific message, you can also search for it in the mailboxes by messageid, and eliminate any ambiguous results from finding other emails that may have a similar subject line.

     


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Tuesday, January 03, 2012 7:37 PM
  • Are you sure you want to do it for all mailboxes? 

     If it's a specific message you want to track, you can get the list of the mailboxes that specific message was delivered to from the message tracking logs, and then use a foreach loop to go through the EWS script for each of those mailboxes.

    By narrowing it down to  a specific message, you can also search for it in the mailboxes by messageid, and eliminate any ambiguous results from finding other emails that may have a similar subject line.

     


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "

    Thanks that worked, but now im trying to export to a csv and its giving me some trouble, I thought it would be good to put every thing into an array and export the array. But the output seams to be the length of the string see below

     

    #Searchs Emails from Yeserday with Subject and If Read or unread
    
    
    
    
    #$MailboxName = $args[0]
    #$MailboxName = "email1@contoso.com"
    #$MailboxName2 = "email2@contoso.com"
    
    $Mailboxes = @("email2@contoso.com","email1@contoso.com")
    
    
    
    $dllpath = "C:\Program Files\Microsoft\Exchange\Web Services\1.1\Microsoft.Exchange.WebServices.dll"
    [void][Reflection.Assembly]::LoadFile($dllpath)
    
    $service = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010_SP1)
    
    $windowsIdentity = [System.Security.Principal.WindowsIdentity]::GetCurrent()
    $sidbind = "LDAP://<SID=" + $windowsIdentity.user.Value.ToString() + ">"
    $aceuser = [ADSI]$sidbind
    
    $service.AutodiscoverUrl($aceuser.mail.ToString())
    
    
    $mailboxlist = @()
    
    foreach ($MailboxName in $Mailboxes){
    
    
    
    $folderid = new-object Microsoft.Exchange.WebServices.Data.FolderId([Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox,$MailboxName)
    
    
    
    $iv = new-object Microsoft.Exchange.WebServices.Data.ItemView(2000)
    $fiItems = $service.FindItems($folderid, "Received:yesterday AND subject:test NOT is:read", $iv)
    foreach ($Item in $fiItems.Items)
    {
       $Item.Subject
       $Item.DateTimeCreated
     #  $Item.ToRecipients
     #  $Item.From
     #  $Item.DisplayTo
     #  $Item.get_IsRead
    
    
     $temp = $Item.Subject, $Item.DateTimeCreated
     $mailboxlist += $temp
    }
    
    }
    
    $mailboxlist | Export-Csv c:\list.csv
    

    the output in the powershell window is fine though......any thoughts?


    test
    Wednesday, January 04, 2012 1:36 PM
  • This might work better:

    $mailboxlist += ($item | select Subject,DateTimeCreated)

     


    [string](0..33|%{[char][int](46+("686552495351636652556262185355647068516270555358646562655775 0645570").substring(($_*2),2))})-replace " "
    Wednesday, January 04, 2012 2:14 PM
  • Worked Great!!! Thanks

     

    Does anyone know if theres a way to tell if the attachment has been opened?


    test
    Wednesday, January 04, 2012 7:01 PM