为用户微软团队分配号码

Assigning number to users microsoft teams

$credential = Get-Credential 
Connect-MicrosoftTeams -Credential $credential
Connect-AzureAD -Credential $credential
Connect-MsolService -Credential $credential
Connect-PnPOnline -Url "https://domain.sharepoint.com/sites/user"

#---------------------------------Call queue
$Util2 = Get-PnPListItem -List "2"

foreach ($temp2 in $Util2) {

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


# Your 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

$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

Set-CsOnlineApplicationInstance -Identity $newCqRa.ObjectId -OnpremPHONENUMBER $CQNum }

我的程序有问题。我正在为存储在 Sharepoint 列表中的多个用户创建一个呼叫队列。在我必须为它们分配 phone 数字的时候,它显示了一个错误。有人可以帮助我吗?

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

注意:当我运行这个程序在单个用户上时它工作正常。

enter image description here

enter image description here

我们刚刚检查了一下,我们能够将 phone 号码分配给用户。您可以尝试使用以下命令来更新用户详细信息吗?

$personList = @{upn='sip:uset1@contoso.com';phoneNumber='tel:+14250000000'},@{upn='sip:uset2@contoso.com';phoneNumber='tel:+14250000001'}

Foreach($item in $personList)
{
Set-CsUser -Identity $item.upn  -EnterpriseVoiceEnabled $true -HostedVoiceMail $true -OnPremLineURI $item.phoneNumber
}