Distribution groups starting with the same name

Welcome Forums General PowerShell Q&A Distribution groups starting with the same name

Viewing 4 reply threads
  • Author
    Posts
    • #259975
      Participant
      Topics: 43
      Replies: 97
      Points: 593
      Rank: Major Contributor

      Hi ,

      I’ve got a script that is removing the users from the distributions groups and 99% this is working like it should.
      However when the user is member of one of the below DistributionGroupsLists
      *All-engineering
      *All-engineering-Vn
      *all_engineering_test
      the script is not able to remove the user from any of these lists and throws an error that multiple entries where found for *all-engineering and stops completely.
      what needs to be modified in the below mentioned code to solve this error?

      thanks for your suggestions

      Paul

      • This topic was modified 3 weeks ago by grokkit. Reason: code formatting - please read the guide
    • #260002
      Participant
      Topics: 25
      Replies: 197
      Points: 718
      Helping Hand
      Rank: Major Contributor

      what is the error being displayed?

      as well, there may be some better approaches just fyi, are you on-premise or in exchange online?

      $clouduser = get-user $userid
      $clouddistmemberships = Get-DistributionGroup -Filter “Members -like ‘$($clouduser.distinguishedName)'” | where isdirsynced -Notlike “*True*”

      this is my approach in term processes to retrieve a users distributiongroup memberships in exchange online

    • #260187
      Participant
      Topics: 43
      Replies: 97
      Points: 593
      Rank: Major Contributor

      HI David,

      thanks for your reaction,
      the error message that I get is this

       

    • #260226
      Participant
      Topics: 25
      Replies: 197
      Points: 718
      Helping Hand
      Rank: Major Contributor

      try using $item.alias
      that should always be unique. you could also try $item.primarysmtpaddress

      you need to utilize a supported parameter that is unique.

      per get-help:
      -Identity <DistributionGroupIdParameter>
      The Identity parameter specifies the distribution group or mail-enabled security group that you want to view.
      You can use any values that uniquely identifies the group.

      For example:
      * Name
      * Display name
      * Alias
      * Distinguished name (DN)
      * Canonical DN
      * Email address
      * GUID

      so you need to pick one of those values, that is distinct. guessing that is whats causing your issue.

    • #260868
      Participant
      Topics: 43
      Replies: 97
      Points: 593
      Rank: Major Contributor

      David,

      the Alias option did solve my problem thanks

       

      Best regards

      Paul

       

Viewing 4 reply threads
  • You must be logged in to reply to this topic.