0

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:

enter image description here

so could this message be the issue? and how can I fix this?

1 Answer 1

1

You can use SharePoint Online Management Shell to connect with multi-factor authentication (MFA) enabled SharePoint site using below command:

Connect-SPOService -Url https://contoso-admin.sharepoint.com

Follow below documentation:

To connect with multi-factor authentication (MFA).


For more information & other ways to login when MFA is enabled, check this thread: Connect-SPOService : The sign-in name or password does not match one in the Microsoft account system

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.