Grant-OuPermissons Lync 2013. Powershell Script

Good Afternoon
Below is a simple script for grant the Ou-permission what are required when deploying Lync 2013 in a restricted or locked down domain/AD.

The below link reference 6 of the attributes that have to have the permissions set. Like most Clients there is never just one container level, and many clients AD drills down through many container levels. Because of this setting the grant-oupermissions would be impossible to do manually, therefore below is a little noddy script which would read an csv. file and upload the contents based on the attributes.

So to confirm to run this script you need a .csv file format of all your OU’s and subOu’s (note: the firstline is the header information)

eg:

Object,DN
User,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”
Contact,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”
AppContact,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”
INetOrgPerson,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”
Device,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”
Computer,”OU=Leeds,OU=Northernlync_Users,DC=northernlync,DC=local”

you need to have the rows for all the object attributes required in the grant-oupermission set

User, Contact, AppContact,Computer, InetOrgPerson, Device

Now copying the below powershell into notepad, then saving it as <name.ps1>, opening it up from the lync management shell you will be presented with a option to specify the <name.csv> file. (you need to save the .csv file into the same place as you’ve save the .ps1 file.)

<<<

param( [string] $importfile = $(Read-Host -prompt `

    “Please enter the csv file name”))

$NorthernLyncArry = Import-Csv $importfile

$transcriptname = “GrantOUPermissions” + (Get-Date `

    -Format s).Replace(“:”,”-“) +”.txt”

Start-Transcript $transcriptname

foreach ($NorthernLyncArry in $NorthernLyncArry)     { Grant-CsOuPermission –ObjectType “$NorthernLyncArry.object” –ou $NorthernLyncArry.ou –Domain “northernlync.local” -Verbose             }

Stop-Transcript

>>>

Add the .csv file name to the prompt and sit back and watch the updating commence.

Simple.!

Regards

Iain Smith

 

Advertisements

One thought on “Grant-OuPermissons Lync 2013. Powershell Script

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s