Clicky

Hi,

I would like to add all users in Active Directory that have the office attribute set to "Turtle" to a distribution group called "Turtle All Staff".

Would this work?
get-recipient -filter {Office-eq "Cayman"} | Add-DistributionGroupMember -Identity "Turtle All Staff"

asked 12/15/2011 04:33

Treadstone21's gravatar image

Treadstone21 ♦♦


3 Answers:
Hello,

Try this:

get-recipient -filter {(Office-eq "Cayman")} | foreach-object {Add-DistributionGroupMember -Identity "Turtle All Staff" -member $_.alias}

JJ
link

answered

jjmck's gravatar image

jjmck

Alternatively, you can create a dynamic distribution group.

new-dynamicdistributiongroup -name "Turtle All Staff" -alias "TurtleAllStaff" -organizationalunit "domain.com/OUToStoreGroupIn" -recipientfilter {(objectclass -eq "user") -and (office -eq "Cayman")} -recipientcontainer "Domain.com"

Would create a dynamic DG that would include all current users and all future users that have an office of Cayman.
link

answered 2011-12-15 at 12:53:35

acbrown2010's gravatar image

acbrown2010

correction, that should be objectclass -eq "usermailbox" not objectclass -eq "user"
link

answered 2011-12-15 at 13:08:12

acbrown2010's gravatar image

acbrown2010

Your answer
[hide preview]

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×70

Asked: 12/15/2011 04:33

Seen: 366 times

Last updated: 12/15/2011 05:38