• How To: Telephony enabling users - continued

    It turned out to be significantly easier to find users without an assigned  LineURI than I expected.  Thanks to Nick Smith for pointing me in the right direction when answering something else. :o)

    The Powershell script takes no parameters and will display the primary SIP URI for all OCS enabled users without a phone number (or LineURI). The count displayed at the end is written to the host so it won’t show in the file if you redirect.

    $OCSUsers = Get-WmiObject -Query "Select * from MSFT_SIPESUserSetting where LineURI IS NULL"
    $i=0
    foreach ($OCSUser in $OCSUsers) {
      $OCSuser.PrimaryURI
      $i++
      }
    Write-Host $i OCS enabled users without LineURI

    The output will be correctly formatted for use with OCSAssignTelUri.wsf

    Happy enabling…

  • How To: Generate multiple phone numbers when telephony enabling users

    Ever needed to generate a list of 100+ phone numbers for use with e.g. OCSAssignTelUri.wsf? I have but couldn’t be bothered with inventing a new method every time anymore, so I wrote a little ps script:

    param ([string] $Series, [string] $Width, [string] $Count)
    if(("-?","-help","-h") -contains $args[0]) {
        Write-Host "This script will generate phone numbers based on a number series"
        Write-Host "Example: .\generatephone.ps1 -Series +1-800-555-1299 -Width 3 -Count 10"
        exit 0
    }
    [int]$Counter = $Series.SubString($Series.Length - $Width, $Width)
    $Base = $Series.Substring(0, $Series.Length - $Width)
    for ($i=1; $i -le $Count; $i++) {
        [string]$strlen = $Counter
        [string]$padding = ""
            for ($x = $strlen.Length; $x -le $Width - 1; $x++) {
                $padding = "0" + $padding
            }
        $Number = $Base + $padding + $Counter
        Write-Output $Number
        $Counter++
    }

    The script will take your base number series, in this case +1-800-555-1299 the width of 3 which allows the script to modify the last 3 digits and finally the count of phone numbers you need.

    Needless to say, there’s no error handling, so if your width goes beyond dashes you get funny results. And if you only allow editing of 2 digits with a count of 100+ – well, you do the math… :o)

    Anywho, just redirect the output to a file with the standard > operator, and Bob’s your uncle. Then you just need a file full of sip:user@domain.com, maybe a fun little project for my summer vacation to extract users without phone numbers…

    Enjoy…