Search | Register | Login 
Forum
Nederlands English
HomeHomeCMShellCMShellGeneralGeneralCreate New Soft Phones and Associate LinesCreate New Soft Phones and Associate Lines
Previous
 
Next
New Post
4/11/2016 5:10 PM
 

I had the need to create a large number of soft phones for summer construction and wanted to avoid doing it manually and/or not having consistent input. I was very happy to find this snappin, but ran into trouble trying to add lines to new phones since there wasn't a New-CMLine cmdlet. I wanted to post in here to save others the hassle in the future.

My installation itself is running through SCCM Software Center and is user-driven. I'm using the PowerShell App Deployment Toolkit to facilitate all installations. In that script I am doing the following things of importance:

<INSTALLATION>
Execute-MSI -Action Install -Path $dirFiles\CiscoIPCommunicatorSetup.msi -Transform $dirFiles\CiscoIPCommunicatorSetup.mst -Parameters "DEVICENAME=`"$envUserName`" TFTP1=`"TFTPIPADDRESS`" /qn /passive  /norestart
<
POST-INSTALL>
Set-RegistryKey -Key "HKCU\SOFTWARE\Cisco Systems, Inc.\Communicator" -Name "AlternateDeviceName" -Type DWord -Value "00000001"

Set-RegistryKey -Key "HKCU\SOFTWARE\Cisco Systems, Inc.\Communicator" -Name "HostName" -Type String -Value "$envUserName"

Set-RegistryKey -Key "HKLM\SOFTWARE\Wow6432Node\Cisco Systems, Inc.\Communicator" -Name "AlternateDeviceName" -Type DWord -Value "00000001"

Set-RegistryKey -Key "HKLM\SOFTWARE\Wow6432Node\Cisco Systems, Inc.\Communicator" -Name "HostName" -Type String -Value "$envUserName"
 

Then in my UCM script to create the phone and link the line I have this so far. I still have to add in CSV support, but this eases the clicking and room for error at least in it's current form. The key was creating that CMLine object to pass into the CMPhone.Lines array. The TemplateSP and TemplateLine were setup manually in the GUI before running this scripts.

#Add PSSnapin for CMShell

Add-PSSnapin -Name CMShell
 
#Connect to UCM
$ucm = Connect-CM -HostName HOSTNAME -UserName ADMIN -Password PWD
 
################################################################################
#Define variables
#Expand to support Import-CSV at a later date
################################################################################
$templateLineNumber = '9999'
$templatePhoneName = 'TemplateSP'
################################################################################
$linePrefix = 'LINEPREFIX '
################################################################################
$deviceName = 'DEVICENAME'
$userFullName = 'USERFULLNAME'
################################################################################
$userLineNumber = 'USERLINENUMBER'
#$userLineNumber = $ucm | Get-CMPhone -Full | ?{$_.Description -eq $userFullName} | Select-Object -ExpandProperty Lines | Select-Object -ExpandProperty Name
################################################################################
$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 .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.Description = 'SP - ' + $userFullName
 
$newPhone.Lines = @()
$newPhone.Lines += $newLine.psobject.ImmediateBaseObject
 
$newPhone | New-CMPhone
 
Previous
 
Next
HomeHomeCMShellCMShellGeneralGeneralCreate New Soft Phones and Associate LinesCreate New Soft Phones and Associate Lines


Privacy Statement
Foxnet BV 2011