powershell - 使用密码登录微软团队
问题描述
使用下面的脚本,我可以在 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
- CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AadAuthenticationFailedException
- FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams
Connect-MicrosoftTeams:出现一个或多个错误。在行:13 字符:1
连接-MicrosoftTeams -Credential $psCred
- CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AggregateException
- FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams
Connect-MicrosoftTeams : unknown_user_type: Unknown User Type At line:13 char:1
连接-MicrosoftTeams -Credential $psCred
- CategoryInfo : AuthenticationError: (:) [Connect-MicrosoftTeams], AdalException
- FullyQualifiedErrorId : Connect-MicrosoftTeams,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams
Connect-MicrosoftTeams : 发生一个或多个错误。: unknown_user_type: Unknown User Type At line:13 char:1
连接-MicrosoftTeams -Credential $psCred
- CategoryInfo : NotSpecified: (:) [Connect-MicrosoftTeams], AadAuthenticationFailedException
- FullyQualifiedErrorId : Microsoft.Open.Teams.CommonLibrary.AadAuthenticationFailedException,Microsoft.Open.Teams.CommonLibrary.ConnectMicrosoftTeams
解决方案
对于此错误: 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>
推荐阅读
- javascript - nodemon 显示正在重新启动服务器,但在对文件进行更改时无法正常工作
- tensorflow - ValueError:检查目标时出错:预期dense_1有2维,但得到了形状为(1188、12、2)的数组
- ios - 收藏视图未显示
- python - 合并满足条件的适应数据框中的行中的列,同时删除行
- google-cloud-platform - 如何在使用 RHEL7 上的 Packer 映像创建 GCP VM 时添加其他磁盘配置
- linux - 为什么我不能使用 -o 或 --format 和 ps 命令来控制输出格式?
- java - 我需要一次接听所有线路并与他们一起工作,但我得到了逐行接收
- php - 在 foreach 循环中每行显示不同的列数
- javascript - CSS :hover 选择器在动态更改后不起作用
- typescript - 如何编写 TypeScript 有意义的接口属性名称而不支付 JS 文件大小