Back to script samples page
Connect to SharePoint Online

These PowerShell commands will connect you to your SharePoint Online service.

This will enable you to administer SharePoint Online using PowerShell as well as configure some settings that are only accessible through PowerShell.

You must also replace the url "https://contoso-admin.sharepoint.com" and use your SharePolint administrative site.

#Connecting to SharePoint Online

#This first command will import the Sharepoint Online module into your PowerShell session.
Import-Module Microsoft.Online.Sharepoint.PowerShell

#Capture administrative credential for future connections.
$credential = Get-credential

#Establishes Online Services connection to SharePoint Online
#You must replace the url "https://contoso-admin.sharepoint.com" and use your SharePoint administrative site.
Connect-SPOService -url https://contoso-admin.sharepoint.com -Credential $credential
Downloaded 877 times
* * * * * (1)
Comments