none
displaying DL members RRS feed

  • Question

  • The script below get the transport rule based on the GUID and then display also the exemption group for that rule. WHat i want is that to display also the member of the exemption group (ex. FromMemberOf) 

    If i check the content of the variable ($group.FromMemberOf) I would see that it has 2 DL groups (pic 1).  But if i try to use FOreach-Object to display further its members i get an error that it cannot convert the identity (pic 2). Is it because the variable being stored is of different type?

    Param(
        [parameter(Mandatory=$true)][string]$sid,
        [parameter(Mandatory=$true)][string[]]$ExchGuid)
        
    # Arrays
    $TRule_Info = @()
    $DL_Info = @()
    $DL_nested = @()
    $From_Member = @()
    $From_MemberInfo = @()

    foreach ($rule in $ExchGuid){
        $TRule_Info = Get-TransportRule | where guid -EQ $rule
            foreach ($group in $TRule_Info){
                $ht = [pscustomobject]@{
                SID = $sid
                RuleID = $group.Guid
                RuleName  = $group.Name
                Reject_Code = $group.RejectMessageEnhancedStatusCode
                Except_MemberOf_DL = $group.ExceptIfFromMemberOf
                Except_SentTo_DL = $group.ExceptIfSentToMemberOf
                SentToMemberOf_DL_BlockGroup = $group.SentToMemberOf
                FromMemberOf_DL_BlockGroup = $group.FromMemberOf                                            
                                               
                }
                                                              

    # Displays the information of the Transport Rule as per defined in var $ht
    $DL_Info += $ht
            }
    }

    $DL_Info


     

    PoSH newbie, BaSH Oldie


    Wednesday, December 4, 2019 11:26 AM

Answers

  • .RawIdentity can help us get the group identity directly, it won't arise the issues about converting type values.

    Here is the contrast of the output:

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    • Marked as answer by navarro_aries Wednesday, December 18, 2019 3:21 AM
    Monday, December 16, 2019 9:04 AM
    Moderator

All replies

  • Hi,

    For test, I used the following command to get the group name directly. It can get the same result as your cmdlets:

    (Get-TransportRule <rule name>).FromMemberOf

    Then use the command to get the distribution group members:

    (Get-TransportRule <rule name>).FromMemberOf.RawIdentity | ForEach {Get-DistributionGroupMember $_ |ft name, RecipientTypeDetails}

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Thursday, December 5, 2019 2:57 AM
    Moderator
  • Just checking in to see if above information was helpful. If you have any questions or need further help on this issue, please feel free to post back.

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Tuesday, December 10, 2019 11:08 AM
    Moderator
  • Thanks this just work. SOmetimes i do overthink my script. THis one is simple as it gets

    PoSH newbie, BaSH Oldie

    Thursday, December 12, 2019 11:56 AM
  • It's great that you get help from replies above. You can mark the useful reply as answer, this may help more people with similar problems. Thanks for your understanding.

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Friday, December 13, 2019 1:04 AM
    Moderator
  • Hi Lydia,

    btw, I saw you adding .RawIdentity why is that so?


    PoSH newbie, BaSH Oldie

    Friday, December 13, 2019 10:08 AM
  • .RawIdentity can help us get the group identity directly, it won't arise the issues about converting type values.

    Here is the contrast of the output:

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    • Marked as answer by navarro_aries Wednesday, December 18, 2019 3:21 AM
    Monday, December 16, 2019 9:04 AM
    Moderator
  • It's great that you get help from replies above, here is a brief summary about this issue. Hope more people can get useful information from it.

    Request:

    The script gets the transport rule based on the GUID and then display also the exemption group for that rule. What i want is that to display also the member of the exemption group (ex. FromMemberOf) 

    If i check the content of the variable ($group.FromMemberOf) I would see that it has 2 DL groups. But if i try to use Foreach-Object to display further its members i get an error that it cannot convert the identity.

    Solution:

    For test, I used the following command to get the group name directly. It can get the same result as $group.FromMemberOf:

    (Get-TransportRule <rule name>).FromMemberOf

    Then use the command to get the distribution group members:

    (Get-TransportRule <rule name>).FromMemberOf.RawIdentity | ForEach {Get-DistributionGroupMember $_ |ft name, RecipientTypeDetails}

    .RawIdentity can help us get the group identity directly, it won't arise the issues about converting type values.

    Regards,

    Lydia Zhou


    Please remember to mark the replies as answers if they helped. If you have feedback for TechNet Subscriber Support, contact tnsf@microsoft.com.

    Wednesday, December 18, 2019 7:02 AM
    Moderator