Powershell

Using Custom Filters For Your Exchange Dynamic Distribution Groups

Dynamic Distribution groups are Distribution groups that dynamically add members into the group based on a certain set of filters and conditions, when an email is sent to the group. These are great for mass mailing a group of users that change can often and managing the group manually would be difficult to maintain.

Exchange offers 2 ways of creating these groups; you can use the EMC/ EAC or PowerShell. I have found that the majority of cases for Dynamic Distribution can be created using the EMC/EAC, which offers the following set of pre-canned filters and conditional.

  • IncludedRecipients
  • ConditionalCompany
  • ConditionalDepartment
  • ConditionalStateOrProvince
  • ConditionalCustomAttribute( 1–15)

There are times that this pre-canned list just doesn’t fit the bill. Let’s say you need a Dynamic Group that filters on users from a certain country or even a particular job title?  PowerShell to the rescue!

PowerShell offers the pre-canned filters as well as any of the account attributes that a user account would have, giving you a lot more freedom to create some customized Dynamic Distribution Group. Please note that you cannot combine pre-canned conditional filters and custom Recipient Filters in the same query.

For example, to create a Dynamic group for mailbox users only in a particular country and company, let’s say the US, use the following cmdlet:

New-DynamicDistributionGroup -Name "TestGroup" -Alias "TestGroup" -OrganizationalUnit "your/OU"-RecipientFilter {(RecipientType –eq  “UserMailbox”) -and (CountryOrRegion –eq “United States”) -and (Company –eq “mycompany”)}

If you have an existing group that you just need to modify to become custom use the Set-DynamicDistributionGroup cmdlet:

Set-DynamicDistributionGroup -Identity "TestGroup" -RecipientFilter {(RecipientType –eq  “UserMailbox”) -and (CountryOrRegion –eq “United States”) -and (Company –eq “mycompany”)}

Note that when creating your Dynamic Distribution Group using PowerShell you cannot combine pre-canned conditional filters and custom Recipient Filters. A list of all the available filterable properties  parameters can be found on TechNet’s site.

http://technet.microsoft.com/en-us/library/bb738157(v=exchg.150).aspx

Advertisement

How to set an Out of Office Message in Powershell

Something that I get asked quite often from our techs is  “can I set Userxx’s Out of Office message?”. Luckily with Exchange 2010, any tech or admin with the correct permissions can easily do that. There are 2 ways ; via the Exchange Control Panel( ECP) or through Powershell. I personally think it’s easier to do it through the shell but the ECP has it advantages too. For instance the ECP can be accessed on any web browser and if you’re configured correctly you can even access it outside of your internal company network.

If you’re like me and you like quick & easy then using Powershell maybe the method for you. To set the OOF using Powershell run the following commands.

Set-MailboxAutoReplyConfiguration pschmitt@youremail.com –AutoReplyState Scheduled –StartTime “1/8/2013” –EndTime “1/15/2013” –ExternalMessage “Type External OOF message here” –InternalMessage “Type Internal OOF message here

You can save this command in a text file and next time you need to set the OOF simply modify the email address and message then copy & paste directly in powershell.

Now wasn’t that simple?