Is there any way to copy a Lync Server policy?
Officially? No, there’s not. We know a lot of people would love to see something like a Copy-CsVoicePolicy cmdlet, but nothing like that exists at the moment, and we don’t know of any plans to create a cmdlet like that in the future. (Although if it’s important enough to you, let us know and we’ll pass those concerns on to the product team.)
Now, in theory, you could write a script that grabs all the property values from one policy and then assigns those same values to another policy; in fact, we have an article that gives you an idea of how this might work. To be perfectly honest, though, that’s not really a solution: it might work with, say, external access policies (which only have a handful of properties), but that would be a nightmare with something like client policies which, at last count, had about 743 gajillion properties.
In other words, not really a solution.
So is there an unofficial, unsupported, we-won’t-even-admit-that-we-told-you-about-it way to copy a policy? Funny you should ask. Let’s say you’d like to make a copy of a per-user policy named RedmondVoicePolicy. In that case, start out by running a command similar to this one:
Get-CsVoicePolicy –Identity “RedmondVoicePolicy” | Export-Clixml –Path “C:BackupsRedmondVoicePolicy.xml”
What did we do with this command? We simply retrieved the voice policy RedmondVoicePolicy, then used the Export-Clixml cmdlet to save an XML copy of that policy (and all its settings) to the file C:BackupsRedmondVoicePolicy.xml.
Now do this. Using Notepad (or another text editor; that’s up to you) open the file RedmondVoicePolicy.xml and look for this line:
As you might have guessed, that’s the line that defines the Identity for the policy. Now, replace RedmondVoicePolicy with the Identity you want to give the new policy. For example, if you want to create a new policy named DublinVoicePolicy you need to modify the Identity tag so it looks like this:
After you’ve made that one little change, save the file and close Notepad.
Now run this command:
Import-Clixml –Path “C:BackupsRedmondVoicePolicy.xml” | Set-CsVoicePolicy
What we’ve done here is use the Import-Clixml cmdlet to read in the XML file, then pipe that object to the Set-CsVoicePolicy cmdlet. And what will Set-CsVoicePolicy do? You got it: it’s going to turn that XML object into a voice policy named DublinVoicePolicy.
Hey, we kid you not; try it and see.
Now, again, this isn’t officially supported, it hasn’t been tested, we can’t guarantee it will work in all situations, etc., etc. But definitely something to keep in mind.