Connect-SPOSite

Connects a SharePoint Online user to a SharePoint Online Site Collection. This cmdlet must be run before any other Site Collection scoped SharePoint Online cmdlets can run.

Connect-SPOSite -Url <UrlPipeBind> [-Credential [<CredentialPipeBind>]] [-NetworkCredentials [<SwitchParameter>]]

Parameters

1

ParameterRequiredTypeDescription
UrlTrueUrlPipeBind

CredentialFalseCredentialPipeBind

NetworkCredentialsFalseSwitchParameter

If specified then the provided credentials must be network credentials and it is assumed that you are connecting to an on-premises version of SharePoint and not SharePoint Online.

Detailed Description

The Connect-SPOSite cmdlet connects a SharePoint Online user to the specified SharePoint Online Site Collection.

Only a single SharePoint Online site connection is maintained from any single Windows PowerShell session. In other words, this is a per-site collection user connection. Running the Connect-SPOSite cmdlet twice implicitly disconnects the previous connection. The Windows PowerShell session will be set to serve the new SharePoint Online user and site collection specified. If you are connecting to an on-premises version of SharePoint and not SharePoint Online then use the -NetworkCredentials switch parameter to treat the provided credentials as network credentials.

Copyright 2016 Falchion Consulting, LLC

> For more information on this cmdlet and others:

> http://blog.falchionconsulting.com/

> Use of this cmdlet is at your own risk.

> Gary Lapointe assumes no liability.

Examples

------------------EXAMPLE 1-----------------------

PS C:\> Connect-SPOSite -Url "https://contoso.sharepoint.com/" -Credential "admin@contoso.com"

This example connects to the Site Collection at https://contoso.sharepoint.com/.

------------------EXAMPLE 2-----------------------

PS C:\> $username = "admin@contoso.sharepoint.com"
PS C:\> $password = "password"
PS C:\> $cred = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $userName, $(ConvertTo-SecureString $password -AsPlainText -Force)
PS C:\> Connect-SPOSite -Url "http://contoso.sharepoint.com/" -Credential $cred

This example connects to the Site Collection at https://contoso.sharepoint.com/ given a specific username and password.