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

相关内容

热门资讯

透视系统!来玩app破解版,a... 透视系统!来玩app破解版,aapoker免费透视脚本,法子教程(都是有挂)-哔哩哔哩1、aapok...
透视软件!wejoker免费脚... 透视软件!wejoker免费脚本,wpk辅助是真的吗,方针教程(本来是真的挂)-哔哩哔哩1、首先打开...
透视工具!wpk德州局怎么透视... 透视工具!wpk德州局怎么透视,智星菠萝可以辅助吗,步骤教程(切实存在有挂)-哔哩哔哩1、任何智星菠...
透视透视挂!拱趴大菠萝万能挂图... 透视透视挂!拱趴大菠萝万能挂图解,德州来玩辅助器,模块教程(都是有挂)-哔哩哔哩1、超多福利:超高返...
透视有挂!wepoker透视脚... 透视有挂!wepoker透视脚本是什么,hhpoker透视脚本下载,大纲教程(竟然真的是有挂)-哔哩...
透视实锤!大菠萝免费辅助,we... 透视实锤!大菠萝免费辅助,wepoker破解工具,步骤教程(确实存在有挂)-哔哩哔哩1、大菠萝免费辅...
透视总结!wepoker辅助器... 透视总结!wepoker辅助器安装包定制,wpk辅助最怕三个东西,妙计教程(确实是有挂)-哔哩哔哩暗...
透视免费!wepoker有没有... 透视免费!wepoker有没有挂,hhpoker辅助软件,要领教程(竟然是真的挂)-哔哩哔哩1、点击...
透视透视!hhpoker德州真... 透视透视!hhpoker德州真的假的,如何下载wepoker安装包,要领教程(确实是有挂)-哔哩哔哩...
透视有挂!wepoker透视辅... 透视有挂!wepoker透视辅助下载,佛手在线有挂吗,指引教程(其实有挂)-哔哩哔哩wepoker透...