Hello Guys,
I am getting really frustrated now as I cannot figure out what is wrong with the following that I will try to describe as best as possible. I am in process of commissioning resource accounts which went pretty well via MSOL powershell. The next step what I had to do is to buy Toll numbers to create call queues, which is fine I managed to purchase 30 numbers. In order to assign the number following MS best practices is to go into Org-wide settings -> Resource accounts -> select the account -> press Assign/unassign -> select Online from the "Phone number type" in the dropdown menu -> type in the desired number which I previously purchased and it couldn't be found.
That's ok I knew this from before but I hoped MS fixed this by now hence giving it a chance. That said and done I turned to powershell and fired up the usual script I am using when I have to do stuff the better way rather than messing with GUI:
Import-Module LyncOnlineConnector
Import-Module SkypeOnlineConnector
Import-module ActiveDirectory
Import-Module MSOnline
Import-Module MicrosoftTeams
Import-Module SkypeOnlineConnector
$CloudCred = Get-Credential "admin@contoso.com"
$session = New-CsOnlineSession -Credential $CloudCred -OverrideAdminDomain "contoso.onmicrosoft.com" -Verbose
Import-PSSession $Session -Allowclobber -verbose
Connect-azuread -accountid admin@contoso.com
Connect-MsolService
Connect-MicrosoftTeams -accountid admin@contoso.com
Which connected me to all the necessary and unnecessary endpoints of MS but that's just my personal preference when working.
That said I wrote this basic foreach block to cycle the numbers for each users pulled from a CSV which contains items: UserPrincipalName,DisplayName,PhoneNumber,ObjectID
$import = Import-Csv -Path C:\PurchasedOnlineNumbers.csv
foreach ($user in $import) {
Set-CsOnlineVoiceApplicationInstance -Identity $user.ObjectID -TelephoneNumber $user.PhoneNumber}
And that threw an error after an error:
The input of parameter "+441234567890" is not in a valid format. Please provide an input with an acceptable format <tel:>+[number]", e.g. +18005551234 or +14251234567.
- CategoryInfo : NotSpecified: (:) [Set-CsOnlineVoiceApplicationInstance], BvdCmdletException
- FullyQualifiedErrorId : TelephoneNumberInvalidFormat,Microsoft.Rtc.Management.Hosted.Bvd.SetVoiceAppEndpointCmdlet
- PSComputerName : admin1e.online.lync.com
Until the cycle finally finished and of course failed. To rule out that the commandlet is not able to read the CSV properly I did a single shot with a single user and a telephone number but got the same results!
What is weird enough earlier today I purchased a test Toll service number which is the same format as the bulk of 30 I bought earlier is assignable running the same command!!!
The real question is, am I missing something out with the script or it's just my MS Tennant needing more time to realise that these numbers are actually owned by it????
Any input would be appreciated guys, I am kinda busted and really need help fast with this one!
Thanks,
Vlatko