Search code examples
powershellmicrosoft-teamsphone-numbermicrosoft-graph-teamscall-queue

Assigning phone number to users microsoft teams


$Util2 = Get-PnPListItem -List "2"

foreach ($temp2 in $Util2) {

$CQNom = $temp2['CQ_nom']
$CQMail = $temp2['CQ_Compte_de_ressource']
$CQNum = $temp2['Tel_sda']    


# config
$cqName = $CQNom

# Create resource account of call queue type
$cqRaParams = @{
UserPrincipalName = $CQMail
# ID taken from cmdlet documentation
ApplicationId     = '11cd3e2e-fccb-42ad-ad00-878b93575e07'
DisplayName       = "RA_$cqName"
}
$newCqRa = New-CsOnlineApplicationInstance @cqRaParams

#Assign licenses to users
$User = Get-AzureADUser -ObjectId $newCqRa.ObjectId
Set-AzureADUser -ObjectId $User.ObjectId -UsageLocation US
$License = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicense
$License.SkuId = "440eaaa8-b3e0-484b-a8be-62870b9ba70a"
$LicensesToAssign = New-Object -TypeName Microsoft.Open.AzureAD.Model.AssignedLicenses
$LicensesToAssign.AddLicenses = $License
Set-AzureADUserLicense -ObjectId $User.ObjectId -AssignedLicenses $LicensesToAssign

#Assign number
Set-CsOnlineApplicationInstance -Identity $newCqRa.ObjectId -OnpremPHONENUMBER $CQNum }

I have a problem with my program. I am creating a call queue for several users who are stored in a Sharepoint list. At the point where I have to assign them phone numbers it shows me an error. Someone can help me ?

The application endpoint was not found in Active Directory.
+ CategoryInfo          : NotSpecified: (:) [Set-CsOnlineApplicationInstance], ApplicationInstanceManagementException 
+ FullyQualifiedErrorId : Microsoft.Rtc.Management.Hosted.PlatformService.ApplicationInstance.ApplicationInstanceMa   nagementException,Microsoft.Rtc.Management.Hosted.PlatformService.ApplicationInstance.SetCsOnlineApplicationInstanceCmdlet  
+ PSComputerName        : api.interfaces.records.teams.microsoft.com


The application endpoint was not found in Active Directory.
+ CategoryInfo          : NotSpecified: (:) [Set-CsOnlineApplicationInstance], ApplicationInstanceManagementException
+ FullyQualifiedErrorId : Microsoft.Rtc.Management.Hosted.PlatformService.ApplicationInstance.ApplicationInstanceMa   nagementException,Microsoft.Rtc.Management.Hosted.PlatformService.ApplicationInstance.SetCsOnlineApplicationInstanceCmdlet
+ PSComputerName        : api.interfaces.records.teams.microsoft.com

A note: when I run this program on a single user it works normally.


Solution

  • We just checked it at our end and we were able to assign the phone numbers to the users. Can you just try with the following command to update the user details.

     $personList = @{upn='sip:[email protected]';phoneNumber='tel:+14250000000'},@{upn='sip:[email protected]';phoneNumber='tel:+14250000001'}
    Foreach($item in $personList)
    {
    Set-CsUser -Identity $item.upn  -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI $item.phoneNumber
    }