while connecting to sharepoint online power shell error coming up

sns 9,226 Reputation points

Although credentials are correct, while connecting to SharePoint online power shell error coming up
Please find attached screenshot

I have used -useweblogin this worked for PnPpowershell but not sharepoint online powershell
However I don't want to use -useweblogin

How should I fix this issue? Please help

FYI: while creating tenant it asked for 2FA so I had to install 2FA app on mobile to authenticate.

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,872 questions
0 comments No comments
{count} votes

Accepted answer
  1. Echo Du_MSFT 17,116 Reputation points

    Hi @sns ,

    Please confirm if you have the required module (and also if you need an update), and use:

    Install-Module -Name Microsoft.Online.SharePoint.PowerShell  

    Then execute the following PowerShell commal

    Connect-SPOService -url https://domain-admin.sharepoint.com  

    After you hit Enter, you will see a familiar Office 365 login page.

    Finally, enter the Admin name and password


    Echo Du


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Vasil Michev 97,076 Reputation points MVP

    Do not use the -Credentials parameter, doing this forces basic authentication, which will not work in your case. Run the cmdlet with just the URL parameter, this will cause a credentials prompt to pop up, similar to the -userweblogin switch for PnP.

  2. sns 9,226 Reputation points

    How to update? Please address

  3. Trevor Seward 11,691 Reputation points

    Run Connect-SPOService https://tenantName-admin.sharepoint.com. This will bring up a dialog box for Modern Auth where you can enter your username/password and complete the MFA prompt.

    0 comments No comments