I want to connect to SharePoint online SharePoint admin center using this code:
Connect-SPOService -url $TenantAdminUrl -Credential $SPCredential
but I keep getting this error:
Message: The underlying connection was closed: An unexpected error occurred on a send.
Stacktrace: at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.Legal.MatterCenter.Common.ConfigureSharePointContext.ConfigureClientContext(String url, String userId, String password)
at Microsoft.Legal.MatterCenter.CreateGroups.Program.AddGroups(Dictionary`2 listval, List`1 groupData)
Message: The underlying connection was closed: An unexpected error occurred on a send.
Stacktrace: at System.Net.HttpWebRequest.GetResponse()
at Microsoft.SharePoint.Client.SPWebRequestExecutor.Execute()
at Microsoft.SharePoint.Client.ClientContext.GetFormDigestInfoPrivate()
at Microsoft.SharePoint.Client.ClientContext.EnsureFormDigest()
at Microsoft.SharePoint.Client.ClientContext.ExecuteQuery()
at Microsoft.Legal.MatterCenter.Common.ConfigureSharePointContext.ConfigureClientContext(String url, String userId, String password)
at Microsoft.Legal.MatterCenter.CreateGroups.Program.DeleteGroups(Dictionary`2 listval, List`1 groupData)
17/06/2022 17:29:00 - Creating group and adding users to it failed
Now I know that Connect-SPOService -url $TenantAdminUrl -Credential $SPCredential
does not work while MFA is enabled. so that why we disable the MFA for all users, and when users try to access any SharePoint site using the web-browser, they will not be asked for MFA, then will just get this message:
so could this message be the issue? and how can I fix this?