Due to a recent site relocation, I was tasked with creating New Lync Common Area Phones that will bs used for the new Conference Rooms at our new location.  Using PowerShell I created the Common Area Phones in Lync.  I did this on one of our Lync Front End Servers using the Lync Server Management Shell.  You MUST do this on a Lync Server with the proper Admin Credentials or it will not work.

I do have another method to pipe the new phones in from a CSV file but due to dodgy networking issues I used this method to ensure that all of them were successful.


Note: I used $LineURI here Set-CSClientPIN -identity $LineURI -pin 123456  Using $DisplayName was causing errors “Not Found in Database”





        Creating a Single New Lync Common Area Phone 
        You MUST run this on a Lync Server 
        To create a new Lync common area phone you will need the Number, Display Name & Description 
        PS C:\> .\New-CommonAreaPhone.ps1 
        Enter in phone number like  972-555-0185 it will be converted for LineURI and DisplayNmumber 
        Enter Display Name 
        Enter Description 
        NAME: New-CommonAreaPhone.ps1 
        VERSION: 3.1 
        AUTHOR: Tim Bolton / Brian Peacock 
        LASTEDIT: 09/18/2013 
# Create New Common Area Phone Enter new phone number, display name & description. 
Do { 
    $Phone=Read-Host "What is the New 10 digit Phone Number? - Example 972-555-0185 " 
    } while ($Phone -match "^\d\d\d\-\d\d\d\-\d\d\d\d$" -ne "True" ) 
Do { 
    $DisplayName=Read-Host "What is the Display Name - Example Phone - BigDog - Executive Conf. Room 197 " 
    } while ($DisplayName.Length -le 5 ) 
Do { 
    $Description=Read-Host "What is the Description - Example Something for the BigDog AD team " 
    } while ($Description.Length -le 5 ) 
# Converts the number for LineURI & DisplayNumber 
    $LineURI"tel:+1" + $Phone.Replace("-""") 
    $DisplayNumber="{0:(###) ###-####}" -$Display 
# That generates the contact object in AD.  Give this about 60 seconds to bake before you run the script (below) against it. 
New-CsCommonAreaPhone -LineUri $LineURI -RegistrarPool "BD-lyncpool.Big.Dog.Com" -DisplayName $DisplayName -DisplayNumber $DisplayNumber -Description $Description -OU "OU=Contacts,OU=Users,DC=Big,DC=Dog,DC=com" 
# Pause 60 Seconds for Lync Changes 
write-host -foregroundcolor Green "Waiting for 60 Seconds Lync Changes to propogate" 
Start-Sleep -s 60 
# Then apply the PIN Number & Policies in order. 
Write-Host -foregroundcolor Yellow "Configuring Lync Policies for $DisplayName " 
Grant-CSPINPolicy -identity $DisplayName -PolicyName "commonareapin" 
Grant-CsVoicePolicy -Identity $DisplayName -PolicyName "BigDog-National" 
Grant-CsDialPlan -Identity $DisplayName -PolicyName "BigDogPlace" 
Grant-CsConferencingPolicy  -Identity $DisplayName -PolicyName "commonareaconferencing" 
Grant-CsClientPolicy -Identity $DisplayName -PolicyName "commonareaclient-nohotdesking" 
# Pause 60 Seconds for Lync Policies 
write-host -foregroundcolor Green "Waiting 30 Seconds Lync Policies to propogate" 
Start-Sleep -s 30 
Write-Host -foregroundcolor Yellow "Configuring Lync PIN for $DisplayName " 
Set-CSClientPIN -identity $LineURI -pin 123456 
#Verify the application of the Policies. 
write-host -foregroundcolor Green "Completeing Tasks" 
Start-Sleep -s 10 
Get-CsCommonAreaPhone –Identity $DisplayName