Script: New-CsClonedPolicy.ps1 – Clones Existing Lync Server 2013/Skype for Business Server 2015 Policy To a New Policy
Description
Some Lync 2013/Skype for Business 2015 policies have few parameters, like User Services Policies. Others, like Conferencing Policies, have a considerable number of parameters. Often, organizations need to have different policies for different groups of people. Many times, there is only one or two settings that are different. Creating a new policy based on an existing policy can be time-consuming. There are some cool utilities like Kevin Peters’ cool StareCompare, which shows where policy settings are different between two policies. But what if it was just easier to “clone” an existing policy to a new policy, and then just change the few settings that need changing? NextHop has a nice article on how to just that. You export the current policy to an XML file, edit the file, then import it into a new policy. Must faster, but still requires some manual editing of an XML file. Ya know why I don’t like that method? Not enough PowerShell! So what I did was write a script that automates that method, and allows you to clone an existing policy to a new policy in one step. The script exports the existing “source” policy, updates the XML, then imports into the “target” policy. One command to make life easier. Then you can use the appropriate “set” cmdlet to tweak the new policy. And it works with all Lync 2013/Skype for Business 2015 policy types, including Archiving, Client, ClientVersion, Conferencing, ExternalAccess, HostedVoicemail, Location, Mobility, NetworkInterSite, PersistentChat, Pin, Presence, UserServices, Voice, and VoiceRouting. The script only works with Lync Server 2013/Skype for Business 2015 policies, and only runs on PowerShell 3.0 or higher (Windows Server 2012 or later).
The script supports Get-Help, so run that if you need additional info.
Syntax
New-CsClonedPolicy.ps1 [[-ExportFolder] ] [[-ExportFile] ] [[-SourcePolicyName] ] [[-TargetPolicyName] ] [[-PolicyType] ] [[-Description] ] []
An example would be
New-CsClonedPolicy.ps1 -SourcePolicyName global -TargetPolicyName "new policy" -PolicyType ConferencingPolicy
This would clone the global conferencing policy into a new policy called “new policy”. Acceptable values for PolicyType are “ArchivingPolicy”, “ClientPolicy”, “ClientVersionPolicy”, “ConferencingPolicy”, “ExternalAccessPolicy”, “HostedVoicemailPolicy”, “LocationPolicy”, “MobilityPolicy”, “NetworkInterSitePolicy”, “PersistentChatPolicy”, “PinPolicy”, “PresencePolicy”, “UserServicesPolicy”, “VoicePolicy”, and “VoiceRoutingPolicy”
When specifying a TargetName, keep one thing in mind. Using just a string value will create a user level policy. If you need to create a site level policy, specify “site:”, such as “site:Redmond” to create a policy for the Redmond site.
Installation
Execution Policy: Third-party PowerShell scripts may require that the PowerShell Execution Policy be set to either AllSigned, RemoteSigned, or Unrestricted. The default is Restricted, which prevents scripts – even code signed scripts – from running. For more information about setting your Execution Policy, see Using the Set-ExecutionPolicy Cmdlet.
Donations
I’ve never been one to really solicit donations for my work. My offerings are created because *I* need to solve a problem, and once I do, it makes sense to offer the results of my work to the public. I mean, let’s face it: I can’t be the only one with that particular issue, right? Quite often, to my surprise, I’m asked why I don’t have a “donate” button so people can donate a few bucks. I’ve never really put much thought into it. But those inquiries are coming more often now, so I’m yielding to them. If you’d like to donate, you can send a few bucks via PayPal at https://www.paypal.me/PatRichard. Money collected from that will go to the costs of my website (hosting and domain names), as well as to my home lab.
Download
v1.3 – 02-03-2017 – New-CsClonedPolicy.v1.3.zip
v1.2 – 06-10-2014 – New-CsClonedPolicy.v1.2.zip
v1.1 – 02-08-2014 – New-CsClonedPolicy.v1.1.zip
v1.0 – 09-03-2013 – New-CsClonedPolicy.v1.0.zip
Changelog
See the changelog for information on what’s changed/included in each version.
Hi, thanks for the script.
In line 96, I had to change $SourcePolicyName by `”$SourcePolicyName`” , otherwise if policy has spaces it would break.
Regards
Fernando
I figured someone would mention this. I already had it fixed in v1.2, but haven’t finished testing the new version yet. Should be out very soon.
Thanks!
The script creates a new policy but it adds the string “Tag:” in front of the new policy name.
This also happens when I use the manual method you mention at the beginning of this post. If think it’s a bug in the parsing engine of the import-clixml commandlet.
That’s automatic in Lync, and as designed.
So you end up with all your copied policies stating with “Tag:” then?
Are you sure it copies global policies correctly???
In global policy:
GlobalMicrosoft.Rtc.Management.ScopeFramework.GlobalScopeAnchorGlobalIn custom policy (example):
Tag(4) DebugTag:DebugYour script result as it is:
GlobalMicrosoft.Rtc.Management.ScopeFramework.GlobalScopeAnchorTest1Your script as it should be by microsoft design:
Tag(>unique ID, incremental<) Test1Tag:Test1Great script. Thanks. I needed it to clone Dial Plans also, so I modified it to accept DialPlan as a policytype, and copied the lines that change the attribute “Name” to the TargetPolicyName and modified them to change the attribute “SimpleName” to TargetPolicyName.
Feel free to send me your changes. My email address is in the header of the script.
Does this script work with SFBO?
It did the last time I tested it, but it’s been a while. Assumption is that you’re already authenticated to O365.