Announcement

Collapse
No announcement yet.

Populate Distribution group with get-recipient query not working

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Populate Distribution group with get-recipient query not working

    I have various recipients that are members of the "Board" group in my Exchange organization. Those recipients are not all Exchange mailboxes. Most of them are simple recipient objects that point to external addresses. However, each object that is related to a board member has "Board" in their "Department" field.

    I want to populate the Board distribution group with those members. I worked out this script (which took an embarrassingly long time -- I'm not as familiar with PowerShell as I should be):

    get-recipient -filter {department -eq "board"} | Add-DistributionGroupMember -Identity "Board Group"
    But I get the following error once for each recipient object that is returned by the get-recipient cmdlet:

    Add-DistributionGroupMember : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input.
    At line:1 char:77
    + get-recipient -filter {department -eq "board"} | Add-DistributionGroupMember <<<< -Identity "Board Group"
    I suspect that it's because the -Identity parameter isn't supplied in Add-DistributionGroupMember and that is where I'm hung up. Not sure how to inlcude the -identity paramter and iterate through each recipient that is in the "Board" department. I suspect some kind of clever for each statement, but haven't gotten proficient enough at PowerShell to figure out how or where to do that.

    Searching on the web for that error message related to the Add-DistributionGroupMember cmdlet brings back little, but a Petri thread is among the returns (no surprise). One of the solutions was to export the desired list of people to a CSV file and then import that CSV file into the group. I'll give that a go, but I'd rather know why I can't pipe my get-recipient returns into Add-DistributionGroupMember. Any ideas?
    Wesley David
    LinkedIn | Careers 2.0
    -------------------------------
    Microsoft Certifications: MCSE 2003 | MCSA:Messaging 2003 | MCITP:EA, SA, EST | MCTS: a'plenty | MCDST
    Vendor Neutral Certifications: CWNA
    Blog: www.TheNubbyAdmin.com || Twitter: @Nonapeptide || GTalk, Reader and Google+: [email protected] || Skype: Wesley.Nonapeptide
    Goofy kitten avatar photo from Troy Snow: flickr.com/photos/troysnow/

  • #2
    Re: Populate Distribution group with get-recipient query not working

    FYI, this is what I did with partial success

    get-recipient -filter {department -eq "board"} | export-csv boardmembers.csv
    and then

    Import-Csv boardmembers.csv | foreach {add-distributiongroupmember "Board" -member $_.email}
    Which almost worked. It seems that a user that had two recipient objects named:

    Bob Smith Hotmail Address
    Bob Smith Yahoo Address

    did not have either entry added to the group. Oh well, I just added him manually. I admit I utilized that last PowerShell statement without being fully aware of what I was doing. On a production box. Good times. Time to bump PowerShell higher on my list of things I'm learning.
    Wesley David
    LinkedIn | Careers 2.0
    -------------------------------
    Microsoft Certifications: MCSE 2003 | MCSA:Messaging 2003 | MCITP:EA, SA, EST | MCTS: a'plenty | MCDST
    Vendor Neutral Certifications: CWNA
    Blog: www.TheNubbyAdmin.com || Twitter: @Nonapeptide || GTalk, Reader and Google+: [email protected] || Skype: Wesley.Nonapeptide
    Goofy kitten avatar photo from Troy Snow: flickr.com/photos/troysnow/

    Comment

    Working...
    X