AzureFunction-PowerShell-在AzureADB2C上调用Connect-MsolService出现TLS版本错误
创始人
2024-09-29 18:00:33
0
  1. 在脚本中添加以下代码,将默认TLS版本更改为1.2:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

  1. 如果还出现错误,请尝试使用以下方法之一:

(a)更新PowerShell版本以支持TLS 1.2

(b)尝试使用其他调用B2C的API(例如Microsoft Graph API)而不是Connect-MsolService函数,因为它们已更新以支持TLS 1.2。

示例代码:

$adminUsername = "[admin_username]" $adminPassword = "[admin_password]" $tenantId = "[tenant_id]" $clientId = "[client_id]" $clientSecret = "[client_secret]" $authority = "https://login.microsoftonline.com/$($tenantId)/"

$context = New-Object Microsoft.IdentityModel.Clients.ActiveDirectory.AuthenticationContext($authority) $context.TokenCache.Clear()

$credential = New-Object "Microsoft.IdentityModel.Clients.ActiveDirectory.UserCredential" -ArgumentList $adminUsername, $adminPassword $token = $context.AcquireToken("$($authority)$($tenantId)", $clientId, $credential)

$headers = @{ Authorization = "Bearer $($token.AccessToken)" 'Content-Type' = "application/json" }

$url = "https://graph.microsoft.com/v1.0/users" $response = Invoke-RestMethod -Uri $url -Headers $headers -Method Get

相关内容

热门资讯

必备教程!wepoker怎么发... 必备教程!wepoker怎么发冤家牌,哈糖大菠萝万能挂,存在挂教程(有挂透视);1分钟了解详细教程(...
透视游戏!智星菠萝可以辅助吗(... 透视游戏!智星菠萝可以辅助吗(透视)好像存在有挂(详细辅助爆料教程)1、进入到智星菠萝可以辅助吗黑科...
重要通知!德普之星透视软件免费... 重要通知!德普之星透视软件免费入口官网,hhpoker是正品吗,攻略方法(有挂攻略);支持2-10人...
透视神器!德扑圈透视(透视)确... 透视神器!德扑圈透视(透视)确实真的是有挂(详细辅助系统教程)1)辅助挂:进一步探索辅助透视大陆,与...
最新技巧!wpk插件,wejo... 最新技巧!wpk插件,wejoker透视方法,必赢方法(有挂辅助);1.wejoker透视方法 ai...
透视app!佛手大菠萝辅助(透... 透视app!佛手大菠萝辅助(透视)原来真的是有挂(详细辅助攻略教程)亲,关键说明,赛季回归,软件透明...
一分钟揭秘!hhpoker到底... 1、一分钟揭秘!hhpoker到底可以作弊码,pokemmo手机版脚本免费,解说技巧(有挂辅助)2、...
透视实锤!steampoker... 透视实锤!steampokermaster辅助(透视)切实是有挂(详细辅助攻略方法);暗藏猫腻,小编...
总算了解!hhpoker视频巡... 总算了解!hhpoker视频巡查真的假的,pokemmo手机脚本,2025新版(有挂方法)是一款可以...
透视好友!约局吧怎么看有没有挂... 透视好友!约局吧怎么看有没有挂(透视)确实是有挂(详细辅助透明挂教程)1、完成的残局,帮助玩家取得所...