Skip to content

Instantly share code, notes, and snippets.

@chrisATautomatemystuff
Created October 26, 2017 11:55
Show Gist options
  • Save chrisATautomatemystuff/9eb7b192a35fd56d28dc8970a8b3d04a to your computer and use it in GitHub Desktop.
Save chrisATautomatemystuff/9eb7b192a35fd56d28dc8970a8b3d04a to your computer and use it in GitHub Desktop.
Configure Cisco Softphones
#REPLACE ANYTHING IN "< >" WITH REAL DATA
#Add PSSnapin for CMShell (http://www.foxnet.nl/CMShell.aspx)
Add-PSSnapin -Name CMShell
#Connect to UCM
$ucm = Connect-CM -HostName <SERVERIP> -UserName <ADMINUSERNAME> -Password <ADMINPWD> -CMVersion 'CM80'
################################################################################
#Define variables
#Expand to support Import-CSV at a later date
################################################################################
$templateLineNumber = '<####>'
$templatePhoneName = 'TemplateSP'
################################################################################
$linePrefix = '<######>'
################################################################################
$deviceName = '<USERNAME>'
$userFullName = '<LAST, FIRST>'
################################################################################
$userLineNumber = '<####>'
################################################################################
$userDisplayName = $userFullName + ' (' + $userLineNumber + ')'
$lineFullNumber = $linePrefix + $userLineNumber
################################################################################
#Retrieve template line
$templateLine = $ucm | Get-CMLine -Name $TemplateLineNumber -Full
#Create a Foxnet.CMServices.CMLineItem object from the template line
#New-CMPhone needs a custom object to add to the <phone>.Lines array
$newLine = $templateLine
#Define new line properties
$newLine.DeviceName = $deviceName
$newLine.Description = $userDisplayName
$newLine.Display = $userDisplayName
$newLine.ASCIIDisplay = $userDisplayName
$newLine.LineText = $userDisplayName
$newLine.ASCIILineText = $userDisplayName
$newLine.ExternalMask = $lineFullNumber
$newLine.AlertingName = $userDisplayName
$newLine.ASCIIAlertingName = $userDisplayName
$newLine.Name = $userLineNumber
#Retrieve template phone
$templatePhone = $ucm | Get-CMPhone -Name $templatePhoneName -Full
#Create a Foxnet.CMServices.CMPhoneItem object from the template phone
$newPhone = $templatePhone
#Define new phone properties
$newPhone.Name = $deviceName
$newPhone.LineNumber = $userLineNumber
$newPhone.Description = 'SP - ' + $userFullName
$newPhone.SoftkeyTemplate = '<TEMPLATE NAME>'
$newPhone.css = 'Internal-css'
$newPhone.Lines = @()
$newPhone.Lines += $newLine.psobject.ImmediateBaseObject
$newPhone | New-CMPhone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment