If you want to connect to a specific SharePoint site with PowerShell, the recommended approach is to use PnP PowerShell and connect with Connect-PnPOnline. Microsoft’s Connect-SPOService cmdlet is used to connect to the SharePoint admin center, not directly to an individual site.
Before you begin, make sure you have:
Run the following command in PowerShell:
If prompted, confirm the installation.
Use the site URL with Connect-PnPOnline:
This opens a Microsoft sign-in window. After successful authentication, your PowerShell session is connected to that specific SharePoint site.
You can test the connection by retrieving information from the site, for example:
If the connection is successful, PowerShell returns details about the SharePoint site. PnP PowerShell includes a large set of SharePoint Online cmdlets for working with sites and related objects.
Connect-SPOServiceIf you use this command:
you are connecting to the SharePoint Online admin center, not to a specific site. This cmdlet is intended for SharePoint administrators and must be run against the -admin.sharepoint.com URL.
If the connection does not work: