I run into this error from time to time. it occurs when connecting via Connect-SPOService and entering the URL for the actual site instead of the one for the SharePoint Online Administration Center.
Solution: Append “-admin” to the first part of the URL as in the following example.
- URL for the site: https://example.sharepoint.com
- URL for the SharePoint Online Administration Center: https://example-admin.sharepoint.com