使用密码登录微软团队

时间:2021-02-24 18:17:27

标签: powershell microsoft-teams

使用下面的脚本,我可以使用秘密在 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”文件中。请确保 在这个目录有适当的保护。

帐户订阅名称 TenantId 环境

xxxxx yyyyyy AzureCloud

账号:xxxxx 环境:AzureCloud 租户:yyyyy 租户 ID : yyyyy 租户域:yyyyy

Connect-MicrosoftTeams:发生一个或多个错误。:unknown_user_type:未知用户类型 在第 13 行字符:1

Connect-MicrosoftTeams -Credential $psCred

  • CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AadAuthenticationFailedException
  • FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

Connect-MicrosoftTeams:发生一个或多个错误。 在第 13 行字符:1

Connect-MicrosoftTeams -Credential $psCred

  • CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AggregateException
  • FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

Connect-MicrosoftTeams:unknown_user_type:未知用户类型 在第 13 行字符:1

Connect-MicrosoftTeams -Credential $psCred

  • CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AdalException
  • FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

Connect-MicrosoftTeams:发生一个或多个错误。:unknown_user_type:未知用户类型 在第 13 行字符:1

Connect-MicrosoftTeams -Credential $psCred

  • CategoryInfo : NotSpecified: (:) [Connect-MicrosoftTeams], AadAuthenticationFailedException
  • FullyQualifiedErrorId : Microsoft.Open.Teams.CommonLibrary.AadAuthenticationFailedException,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams

1 个答案:

答案 0 :(得分:0)

对于此错误:Connect-MicrosoftTeams:unknown_user_type:Unknown User Type 在第 13 行字符:1 您需要传递凭据 - 用户名和密码而不是机密。 你能不能试试这个命令 - Connect-MicrosoftTeams [-TenantId] -AadAccessToken [-MsAccessToken] [-ConfigAccessToken] -AccountId [-LogLevel] [-LogFilePath] [-WhatIf] [-Confirm] [] –