You have to give your SharePoint admin site url as root scope when you work with SharePoint online PowerShell module and SharePoint Client Object Model (CSOM). The possible admin site url would be like below sample url.
https://tenantname-admin.sharepoint.com/
Consider your office 365 user id (userPrincipalName) is : “[email protected]” and most probably your tenant name is “contoso” then your sharepoint admin site url should be below one.
https://contoso-admin.sharepoint.com/
You can test the url is correct or not by using this url as root scope with SharePoint Online Powershell module. The below connect your sharepoint admin site and list all sites.
Connect-SPOService -url "https://contoso-admin.sharepoint.com" Get-SPOSite | Select Title, Url
You can also get the correct url by connecting Office 365 Admin center site:
- Go to Office 365 Admin center.
- In the left navigation, expand Admin centers, and then select SharePoint.
- Now, you can view your admin site and get the correct admin site url as shown in below image.
Advertisement