So after I wrote this post my mind spun a little and I thought: “Why should I limit it to just the Get-CsMobilityPolicy cmdlet. Can’t I make this much more flexible?” And so I did. I’ve now upgraded the script so that you can use several different cmdlets and several different parameters to recursively update values in an Active Directory security group.
The command line now has expanded to 5 mandatory variables from 3:
Parameter 1: The cmdlet you want to run, such as Grant-CsMobilityPolicy, Grant-CsConferencingPolicy, or even Set-CsUser. I have only tested these 3 but I am sure some others will work too.
Parameter 2: The Full DN of the target group. For example “CN=Detroit Users,OU=Distribution Groups,OU=MI,DC=NorthAmerica,DC=flincbot,DC=com” or “CN=Domain Users,CN=Users,DC=flinchbot,DC=com”
Parameter 3: The name of a domain controller to go against. For example miadc01.northamerica.flinchbot.com or dc1.flinchbot.com
Parameter 4: The attribute in parameter 1 to modify. For example PolicyName or ArchivingPolicy.
Parameter 5: The Value to assign. For example “tag:Enable Mobility”, “tag:UserConferencing”, or “tag:ArchivingPolicy”
Here are three example commands to get you started:
.Set_CsAttribute.ps1 Grant-CsMobilityPolicy “CN=Detroit Users,OU=Distribution Groups,OU=MI,DC=NorthAmerica,DC=flincbot,DC=com” miadc01.northamerica.flinchbot.com PolicyName “tag:Enable Mobility”
.Set_CsAttribute.ps1 “grant-csconferencingpolicy” “CN=Domain Users,CN=Users,DC=distressler,DC=com” “dc1.distressler.com” “PolicyName” “tag:UserConferencing”
.Set_CsAttribute.ps1 “set-csuser” “CN=Domain Users,CN=Users,DC=distressler,DC=com” “dc1.distressler.com” “ArchivingPolicy” “tag:ArchivingPolicy”
Note that I have only done minimal testing with this version of the script. The previous script worked successfully for me in production but I have yet to use this one outside of a lab environment. But use this at your own risk. Any mistakes caused by running this script are your fault, not mine!
And for a more rounded view of this, check the previous article.
You can grab the script here:
[office src=”https://skydrive.live.com/embed?cid=31E64FCE17A6E0B2&resid=31E64FCE17A6E0B2%215117&authkey=AIA0hSuq3TEd9tE” width=”98″ height=”120″]