Exchange: Addresslist and Dynamic Distribution Groups in Shell

by butsch 14. June 2016 20:13

All you need are working samples not thousands lists and Technet Articles. So here we go with some Exchange Powershell we daily use.

Maybe you want a lists of all fields so you can choose one to use for the filter first.

Get all user info from a certain OU

Starting OU would be:

 

OU=Active,OU=Users_W7,OU=BUTSCH,DC=butsch,DC=ch

Get-ADUser -filter * -SearchBase "OU=Active,OU=Users_W7,OU=BUTSCH,DC=butsch,DC=ch" -Properties * | select-object givenname, sn, displayname, description,office, streetaddress,city,st,postalcode,country, title, Department, company | ConvertTo-Csv –NoTypeInformation

 

Exchange 2010 Addresslist and Dynamic Distribution Groups (E-Mail Distribution)

 

Exchange 2010 Addresslist

Generate Exchange Addresslist with starting OU, OPATH filter for CITY and STREET

new-AddressList -Name 'Mitarbeiter Nestle Suisse – W110' -RecipientContainer 'butsch.ch/BUTSCH/Users_W7/Active' -IncludedRecipients 'MailboxUsers' -Container '\' -DisplayName 'Mitarbeiter Nestle Suisse – W110'

set-Addresslist -identity 'Mitarbeiter Nestle Suisse – W110' -RecipientFilter {(ObjectClass -eq 'user' -and City -eq 'Lausanne' -and StreetAddress -eq 'Roberstenstrasse 133' )}

 

Remark: DO not try to add other additional GAL-addresslists because they will appear in the ROOT of the Adressbook. You can't filter all you can with regular Addresslist and you will be limited when you migrate those to later Exchange versions.

Dynamic Distribution Groups

 

Generate Exchange Dynamic Distribution Groups with OU, OPATH filter for CITY and STREET

This will generate a DynamicDistributionGroup which is located in "'butsch.ch/BUTSCH/Groups/Mail'" and will list all members of OU 'butsch.ch/BUTSCH/Users_W7/Active'. With the second command we filter to show ONLY the employees who have the field city and Streetaddress with a certain value.

 

 

This is a TWO part and it ONLY works in two commands. Forget it and don't try.

 

new-DynamicDistributionGroup -Name 'Alle Mitarbeiter Nestle Suisse' -RecipientContainer 'butsch.ch/BUTSCH/Users_W7/Active' -IncludedRecipients 'MailboxUsers' -OrganizationalUnit 'butsch.ch/BUTSCH/Groups/Mail' -Alias 'Alle_Mitarbeiter_Nestle Suisse'

 

set-DynamicDistributionGroup "Alle Mitarbeiter Nestle Suisse" -RecipientFilter {(ObjectClass -eq 'user' -and City -eq 'Lausanne' -and StreetAddress -eq 'Roberstenstrasse 133' )}

 

If you want to change the FIELD you search for check:

Filterable properties for the -RecipientFilter parameter

https://technet.microsoft.com/de-de/library/bb738157(v=exchg.150).aspx

Manage the Members of Distribution Groups

https://technet.microsoft.com/en-us/library/hh859493(v=exchg.141).aspx

Upgrade Custom LDAP Filters to OPATH Filters

https://technet.microsoft.com/en-us/library/cc164375(v=exchg.141).aspx

 

Tags:

Exchange 2010 | Exchange 2013

Comments are closed

Werbung von Drittfirmen (Nicht Butsch Informatik):

Werbung von Drittfirmen via Google Adsense: