Jump to content

Ordering Speed dials in alphabetical order


BurningRabbit

Recommended Posts

  • Most Valued User

Use PowerShell Luke!

 

Something along the lines of:

Get-IpPbxSpeedDialKey -UserName "James Bond" | Where-Object {$_.Label -ne "-" -and $_.Label.Length -gt 0} | Sort-Object label | Update-IpPbxSpeedDialKey -UserName "James Bond"

 

Link to comment
Share on other sites


  • Most Valued User

Sure

Try 

Get-IpPbxSpeedDialKey -UserName "James Bond" | Where-Object {$_.Id -lt 100} | Sort-Object label | Update-IpPbxSpeedDialKey -UserName "James Bond"

Not sure what happens to the other SDKs.  Worst case, you'll have omit the last piped command and save the result to a variable, and then iterate over and insert them in the correct position.

Link to comment
Share on other sites


  • 1 month later...

Hi - I am very new to Powershell (and sadly am certainly not a developeror or generally any sort of coder), but was looking at this as I think that it is something that could be very useful indeed to me in administering a number of systems. Please see the commands below, which omit Varmenni's Update-IpPbxSpeedDialKey part.


PS C:\> Get-IpPbxSpeedDialKey -UserName "Administrator" | Where-Object {$_.Label -ne "-" -and $_.Label.
Length -gt 0} | Sort-Object label

 

   Id Label                     Number               DialImmediately DeleteBeforeDial Intercom   UserBitmap
   -- -----                     ------               --------------- ---------------- --------   ----------
    0 Andy                     12345                True            True             False      Automatic
   27 Barry                      66547                True            True             False      Automatic
    2 William                 5874                 True            True             False      Automatic
    1 Zac                     54321                True            True             False      Automatic


I find that the speed dials are indeed sorted in the correct order, but retain their original ID's. This means that when you pipe the line above to Update-IpPbxSpeedDialKey, the speed dials remain in the same positions on the skin.

 

Is there a way that anybody can suggest that would update the ID's as well, so that in addition to putting the entries into alphabetical order, the ID's are set to occupy the first X speed dial keys.

 

For example, in my example above, I would want to see: Andy = Id 0, Barry = Id 1, William = Id 2, Zac = Id 3. Thus, when the objects are piped to Update-IpPbxSpeedDialKey, they would then occupy the first 4 speed dial keys for the user.

 

By the way - Excellent suggestion by Varmenni - This gets me a good way along the track to something very useful for me. Thank you.

 

 

Link to comment
Share on other sites


  • 7 months later...

It's been a long time since I last commented on this post but just thought that I would give a bit of feedback on this, as I have created a Powershell script that will read all of the User names within a group on a Swyx server and then write these usernames to the speed dials of all users in alphabetical order. I have borrowed elements from other Powershell posts on the forum. As I think this is quite useful, I also thought it might help others on the Forum.

 

I found that I was unable to pipe the following into Update-IpPbxSpeedDialKey:

Get-IpPbxSpeedDialKey -UserName "Administrator" | Where-Object {$_.Label -ne "-" -and $_.Label.
Length -gt 0} | Sort-Object label

 

Therefore, I have taken a different direction. The following is a script that I adapted from the October 2014 script (on the archive forum) that relates to modifying speed dials with Powershell. As I am not a developer and just achieved this by trial-and-error, it is likely nowhere near as concise as it could be, but I thought I would share it anyway as it might be of use to someone. Just copy the text below into a text file and save with a .ps1 extension. The script below sets all users from the Everyone Group as speed dials. Changing Everyone to another group uses the other group instead.

 

Import-Module IpPbx

 

Connect-IpPbx

 

$GroupName = "Everyone"
$Swyxusers = Get-IpPbxGroupMember -GroupName $GroupName | Sort-Object -Property Name

 

Get-IpPbxGroupMember -GroupName $GroupName | ForEach-Object {
    $i = 0
    foreach ($Swyxuser in $Swyxusers) {
        $EntryTitle = $Swyxuser.Name
        if ($EntryTitle -ne $_.Name) {
            $InternalNumber = Get-IpPbxInternalNumber -UserName $EntryTitle
            $sdk = Get-IpPbxSpeedDialKey -UserEntry $_ -SpeedDialKeyId $i
            $sdk.DialNumber = $InternalNumber.Number
            $sdk.Label = $EntryTitle
            Update-IpPbxSpeedDialKey -UserEntry $_ -SpeedDialKey $sdk
            $i = $i+1
        }
    }
}

 

As I say, it might be a bit long-winded or have unnecessary information, but hopefully it is useful to someone else.

Link to comment
Share on other sites


  • 2 years later...
On 1/19/2016 at 9:34 PM, 5wyx1t said:


Is there a way that anybody can suggest that would update the ID's as well, so that in addition to putting the entries into alphabetical order, the ID's are set to occupy the first X speed dial keys.

For example, in my example above, I would want to see: Andy = Id 0, Barry = Id 1, William = Id 2, Zac = Id 3. Thus, when the objects are piped to Update-IpPbxSpeedDialKey, they would then occupy the first 4 speed dial keys for the user.

 

 

 

This topic has not been updated for a while, but I could not find a more current one...

 

@5wyx1t - I was trying to solve the same problem, again via Swyx PowerShell.  The solution below is certainly not perfect but it seems to work OK.  It resolves your original ID problem.

 

I have deliberately left the long hand loops and comments, just so someone can follow the logic if they need to.  It could be more efficient.  This works by:

 

- reading the speed dials of a specific user

- putting them in alpha order

- writing the clean list over the top of the existing speed dials

- removing all the left over speed dials, below the now cleaned list

 

Note: The images will look wrong at first, but will sort themselves out once the user logs out and back in again.

 

 

# set the target user
$swyxuser = "Joe Bloggs"

 

# get the speed dials, sort them and remove the blank ones
$keylist = Get-IpPbxSpeedDialKey -username $swyxuser
$keylistsort = Get-IpPbxSpeedDialKey -Username $swyxuser | Sort-Object label
$keylistsortclean = Get-IpPbxSpeedDialKey -Username $swyxuser | where-object {$_.Label -ne $null} | Sort-Object label

 

# set a counter for the number of non-blank speeddials
$sdcount = $keylistsortclean.count
$loop = $sdcount
$loop--

 

# write the speed dials back into the user from position 0 in alpha order
for ($i=0; $i -le $loop; $i++){
Add-IpPbxSpeedDialKey -SpeedDialKey $keylistsortclean[$i] -Username $swyxuser -SpeedDialKeyId $i
}

 

# set a counter to wipe the left over speed dials
$totalsdcount = Get-IpPbxSpeedDialKeyCount -Username $swyxuser
$loop = $totalsdcount
$loop--

for ($i=$sdcount; $i -le $loop; $i++){
Remove-IpPbxSpeedDialKey -UserName $swyxuser -SpeedDialKeyId $i -Confirm:$false
}

 

Link to comment
Share on other sites


Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and have taken note of our Privacy Policy.
We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.