首页 > 解决方案 > 使用密码登录微软团队

问题描述

使用下面的脚本,我可以在 AzureAd 上使用机密进行身份验证,但不能在团队中进行身份验证。您能否指出正确的方向如何为 MicrosoftTeams 执行此操作?

import-module Az
Import-Module MicrosoftTeams
$azureAplicationId ="xxxx"
$azureTenantId= "yyyyy"
$azurePassword = ConvertTo-SecureString "secret" -AsPlainText -Force
$psCred = New-Object System.Management.Automation.PSCredential($azureAplicationId , $azurePassword)
Connect-AzAccount -Credential $psCred -TenantId $azureTenantId -ServicePrincipal
$context = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile.DefaultContext
$aadToken = [Microsoft.Azure.Commands.Common.Authentication.AzureSession]::Instance.AuthenticationFactory.Authenticate($context.Account, $context.Environment, $context.Tenant.Id.ToString(), $null, [Microsoft.Azure.Commands.Common.Authentication.ShowDialog]::Never, $null, "https://graph.windows.net").AccessToken

Connect-AzureAD -AadAccessToken $aadToken -AccountId $context.Account.Id -TenantId $context.tenant.id

Connect-MicrosoftTeams -Credential $psCred

输出:

警告:提供的服务主体机密将包含在用户配置文件 (C:\Users\jdeclerc.Azure) 中的“AzureRmContext.json”文件中。请确保此目录具有适当的保护措施。

Account SubscriptionName TenantId 环境

xxxxx yyyyyy AzureCloud

帐户:xxxxx 环境:AzureCloud 租户:yyyyy TenantId:yyyyy TenantDomain:yyyyy

Connect-MicrosoftTeams : 发生一个或多个错误。: unknown_user_type: Unknown User Type At line:13 char:1

连接-MicrosoftTeams -Credential $psCred

Connect-MicrosoftTeams:出现一个或多个错误。在行:13 字符:1

连接-MicrosoftTeams -Credential $psCred

Connect-MicrosoftTeams : unknown_user_type: Unknown User Type At line:13 char:1

连接-MicrosoftTeams -Credential $psCred

Connect-MicrosoftTeams : 发生一个或多个错误。: unknown_user_type: Unknown User Type At line:13 char:1

连接-MicrosoftTeams -Credential $psCred

标签: powershellmicrosoft-teams

解决方案


对于此错误: Connect-MicrosoftTeams : unknown_user_type: Unknown User Type At line:13 char:1 您需要传递凭据 - 用户名和密码而不是密码。你能试试这个命令吗 - Connect-MicrosoftTeams [-TenantId ] -AadAccessToken [-MsAccessToken ] [-ConfigAccessToken ] -AccountId [-LogLevel ] [-LogFilePath ] [-WhatIf] [-Confirm] [] –</p>


推荐阅读