none
PS Script for Journaling Rule Reports - Exchange 2010 RRS feed

  • Question

  • I'm trying to put together a script that will get all Journal Rules in Exchange and list the Rule Name , Recipients Journaled(display name and email address), and Journaling address. I'm halfway there but cannot figure out how to expand the distro list of the recipients journaled(they are almost all distro lists but a few are single users) and export it all out to csv. In other words, I don't know how to tie in the get-distributionmember cmdlt when needed. Your help is greatly appreciated

    This is what I have so far:

    $Rule = Get-JournalRule
    if ($Rule.Recipient -ne '*singleuserdomain.com*')

    {
    Get-DistributionGroupMember $Rule.Recipient | select Displayname,primarysmtpaddress | Export-Csv c:gtest1.csv
    }











    • Edited by MS Water Wednesday, April 22, 2015 9:28 PM
    Wednesday, April 15, 2015 2:32 PM

Answers

  • Hi,

    Here is the script:

    You might want to change the formatting as per your requirements. Currently output is strictly text based.

    $Rules = Get-JournalRule 
    
    
    ForEach ($Rule in $Rules)
    {
    
    $email = $Rule.Recipient.local+"@"+ $Rule.Recipient.Domain
    
    $Obj = Get-Recipient | ?{$_.PrimarySmtpAddress -eq $email}
    
    "-------------------------------------------------------"
    $Rule
    #"RuleName: "+ $Rule.Name
    
    if($Obj.RecipientType -eq "MailUniversalDistributionGroup") 
    {
    Write-host "DL Name: "  $Obj.Name
    Write-host "DL Members:"
    Get-DistributionGroupMember $Obj | ft Displayname,primarysmtpaddress,RecipientTypeDetails -Autosize
    }
    else
    {
    #Write-host "Mailbox Details:"
    Get-Mailbox $Obj.Name | ft Displayname,primarysmtpaddress,RecipientTypeDetails -Autosize
    }
    }

    Sample Output:

    [PS] C:\Scripts>.\JournalRuleList.ps1
    -------------------------------------------------------
    
    
    Name                : JournalDLRule2
    Recipient           : JournaledDL@mycompany.com
    JournalEmailAddress : satyajit@mycompany.com
    Scope               : Global
    Enabled             : True
    
    DL Name:  JournaledDL
    DL Members:
    
    
    
    DisplayName PrimarySmtpAddress   RecipientTypeDetails
    ----------- ------------------   --------------------
    User1       User1@mycompany.com            UserMailbox
    User10      User10@mycompany.com           UserMailbox
    User11      User11@mycompany.com           UserMailbox
    User12      User12@mycompany.com           UserMailbox
    User100     User100@mycompany.com          UserMailbox
    
    
    -------------------------------------------------------
    
    
    Name                : TestJournalRule
    Recipient           : User1@mycompany.com
    JournalEmailAddress : satyajit@mycompany.com
    Scope               : Global
    Enabled             : True
    
    
    
    
    DisplayName PrimarySmtpAddress RecipientTypeDetails
    ----------- ------------------ --------------------
    User1       User1@mycompany.com          UserMailbox
    
    
    [PS] C:\Scripts>



    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by MS Water Tuesday, May 12, 2015 5:20 PM
    Wednesday, April 29, 2015 7:14 PM

All replies

  • Hi MS Water,

    Journal recipient   Specifies the SMTP address of the recipient you want to journal.

    If the Journal recipient is a DL, then any email sent to this DL will be journalled and emails sent to the individual members of the DL.

    If you specify a distribution group as the journaling recipient, all messages sent to or from members of the distribution group are journaled.


    For each recipient addressed on a message, one recipient journal report field is added. No recipient field contains more than one recipient e-mail address, except as follows:

    • Recipient fields that contain recipients that have been expanded from a distribution group

    • Recipient fields that contain recipients that have received a message forwarded from another mailbox

    For expanded or forwarded messages, the e-mail address of the recipient that received final delivery of the message and the e-mail address of the distribution group or mailbox that was originally addressed are included.

    If you still need, I'll try to look out for correcting your cmdlet statement.

    References:

    Understanding Journal Reports

    Journal rules -2013


    Regards,

    Satyajit

    Please“Vote As Helpful” if you find my contribution useful or “MarkAs Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.



    • Edited by Satyajit321 Wednesday, April 29, 2015 6:25 PM Correction
    Wednesday, April 29, 2015 6:16 PM
  • Hi,

    Here is the script:

    You might want to change the formatting as per your requirements. Currently output is strictly text based.

    $Rules = Get-JournalRule 
    
    
    ForEach ($Rule in $Rules)
    {
    
    $email = $Rule.Recipient.local+"@"+ $Rule.Recipient.Domain
    
    $Obj = Get-Recipient | ?{$_.PrimarySmtpAddress -eq $email}
    
    "-------------------------------------------------------"
    $Rule
    #"RuleName: "+ $Rule.Name
    
    if($Obj.RecipientType -eq "MailUniversalDistributionGroup") 
    {
    Write-host "DL Name: "  $Obj.Name
    Write-host "DL Members:"
    Get-DistributionGroupMember $Obj | ft Displayname,primarysmtpaddress,RecipientTypeDetails -Autosize
    }
    else
    {
    #Write-host "Mailbox Details:"
    Get-Mailbox $Obj.Name | ft Displayname,primarysmtpaddress,RecipientTypeDetails -Autosize
    }
    }

    Sample Output:

    [PS] C:\Scripts>.\JournalRuleList.ps1
    -------------------------------------------------------
    
    
    Name                : JournalDLRule2
    Recipient           : JournaledDL@mycompany.com
    JournalEmailAddress : satyajit@mycompany.com
    Scope               : Global
    Enabled             : True
    
    DL Name:  JournaledDL
    DL Members:
    
    
    
    DisplayName PrimarySmtpAddress   RecipientTypeDetails
    ----------- ------------------   --------------------
    User1       User1@mycompany.com            UserMailbox
    User10      User10@mycompany.com           UserMailbox
    User11      User11@mycompany.com           UserMailbox
    User12      User12@mycompany.com           UserMailbox
    User100     User100@mycompany.com          UserMailbox
    
    
    -------------------------------------------------------
    
    
    Name                : TestJournalRule
    Recipient           : User1@mycompany.com
    JournalEmailAddress : satyajit@mycompany.com
    Scope               : Global
    Enabled             : True
    
    
    
    
    DisplayName PrimarySmtpAddress RecipientTypeDetails
    ----------- ------------------ --------------------
    User1       User1@mycompany.com          UserMailbox
    
    
    [PS] C:\Scripts>



    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    • Marked as answer by MS Water Tuesday, May 12, 2015 5:20 PM
    Wednesday, April 29, 2015 7:14 PM
  • Thanks Satyajit!

    You know what you were right. They are actually AD Groups and not dl lists by definition. The reason I need to list them out is for an Excel report to see which users are actually getting journaled(as they should all be a part of that security group). So, I'm thinking all I'd have to do with the script you provided would be to instead use the Get-ADGroupMember cmdlet and not the Get-DistributionGroupMember, and then export the output to csv, correct?

    Thanks again



    • Edited by MS Water Wednesday, April 29, 2015 7:30 PM
    Wednesday, April 29, 2015 7:28 PM
  • Hi MS Water,

    You might try using the Get-ADGroupMember as well. However you need to change the If(Condition) to correctly detect User or Group.

    Even though the command says Get-DistributionGroupMember, it can very well extract mail enabled security groups. The reference to DL here is basically to Mail-Enabled Group

    Just to cover up the Security Groups as well, update the if condition as below:

    if($Obj.RecipientType -eq "MailUniversalDistributionGroup" -or $Obj.RecipientType -eq "MailUniversalSecurityGroup")

    To get the output in Excel, you can catch the results in a variable and loop it through to re-format it. 

    This only covers Groups and UserMailboxes. But if you want to cover more types, you might want to look at the Get-Recipient cmdlet:

    The RecipientType parameter specifies the type of recipients to return. You can use one or more of the following values:

    • DynamicDistributionGroup

    • UserMailbox

    • MailUser

    • MailContact

    • MailUniversalDistributionGroup

    • MailUniversalSecurityGroup

    • MailNonUniversalGroup

    • PublicFolder

    References:

    Manage mail-enabled security groups


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    Thursday, April 30, 2015 3:43 AM
  • Hi MS Water,

    Any updates on this. Please let us know, if it wokred for you.


    Regards,

    Satyajit

    Please “Vote As Helpful” if you find my contribution useful or “Mark As Answer” if it does answer your question. That will encourage me - and others - to take time out to help you.

    Monday, May 4, 2015 11:51 AM
  • Thanks, Satyajit.
    Tuesday, May 12, 2015 5:22 PM