Modifying Exchange Labs Custom Attributes using PowerShell

Since I first posted on the potential for using Exchange Custom attributes for things like supporting the creation of Distribution Groups, profiling of your user population and so on, I have had queries from customers about how these attributes can be manipulated in bulk.  We do provide a CSV import tool as readers of this blog will know, but in its current version, it does not support the modification of these attributes.  The way to do it is through PowerShell.  What I have done is to modify the CSV_Parser.psi script to include support for these attributes for both mailbox users and mail users by first of all declaring the Custom Attribute variables at the start of the script, and then adding the set-mailbox line the the Action sections for Adds and Updates.

Declared new variables:

Added set-mailbox line:

%{Invoke-Command -Runspace $rs1 {param ($this_name,$this_CustomAttribute1,..,$this_CustomAttribute15) set-mailbox -Identity $this_name -CustomAttribute1 $this_CustomAttribute1 … -CustomAttribute15 $this_CustomAttribute15}-arg $this_name,$this_CustomAttribute1,…,$this_CustomAttribute15}

set-mailbox is the cmdlet that supports the Custom Attributes.

Double click to view in full screen


As usual, the script I used is available here (use at your own risk), along with the sample csv file and steps I took in the screencast.  When you run the script, you will see that as it cycles through each mailbox, it will first of all modify the regular attributes (such as Department) and then the custom attributes.  If you do not modify any of the regular attributes, the script will first of all echo that no attributes have been updated, and then that the custom attributes have been updated.  This may not be as elegant as some of your would like…in fact some people may prefer to create a stand-alone script that just deals with the Custom Attributes in isolation.  I will leave that up to you to decide…again, I recommend that you take the time to understand what the script does so that you can start making your own modifications.





Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: