Friday, September 30, 2011

A quick note to self on adding many locations through PowerShell

I must admit; On most of my Lync installations, bandwidth has not been an issue for me to worry about. Or, I've been adding just a few sites and policies manually through CSCP.

Well, this week all of that changed. A customer I'm working with these days, are implementing a full PBX replacement with Lync Ent Voice and BW is a major issue at several sites (at least until the customer gets to upgrade). They sent me a list of 100 sites with 10Mb or less on their wan links connected to the main site.

I was taken aback on the proposed amount of time I would spend typing, if all of this was to be entered manually into the system. But thanks to the import-csv and foreach functions of powershell, I was able to save a lot of time.

I sat down and discussed a few options for the customer, and decided to narrow it all down to a set of three profiles to keep things simple. (If you're intrested in my way of reasoning on cac, and why it is important, you might want to read my previous post on the matter)

I spent some time tweaking the script, and made a few test-runs using -whatif, but in the end, I was done configuring the system before lunch (An I thought I would spend days typing this manually).

The "trick" is as always, to gather the information in a readable csv-file. Then add a header row on which the import job can sort things on. Here is a sample of my file (total fiction, but real enoug). Notice how I use the "," as the seperator, not the ";" as is the default when saving from Excel:

I've shortened the list to 30 locations, just for the example. And using "Location 1" isn't the most descriptive name, but you'll get the point.

With this file at hand, I created the following script make it all happened. As my script filter on the "BW" column, I had to run this script X-times (where X = the number of XXMB variations in the file), selecting the chosen profile each time. If you are going to use this script yourself, you only run the "New-CsNetworkBandwidthPolicyProfile" once. Either remove it, or remark it out before running it over and over again.


I know this is a really simple implementation of CAC, as I haven't touch upon regions and region links in here. But that might be food for another post down the road.

If you want more reading material on the subject, I can recommend the planning section and deployment section of the Lync Library on Technet

That's how easy your life can get with the power of powershell :) I was not thrilled when first introduced, but now I'm getting quite fond of it. I might even see the need for a course, or at least buy a book on the subject soon.
For your convenience, I have the sample script and file right here to download :)