-->

June 6, 2018

Connect To SharePoint Online With PowerShell

Use PowerShell To Access SharePoint Online


First download SharePoint Online Management Shell from Microsoft download center here to get the PowerShell module for SharePoint Online.


The following prerequisites are mandatory to pursue the installation of the PowerShell module:

When the SharePoint Management Shell is downloaded, double click on it and hit "install" as described on the image below:

SharePoint Online Management Shell

To manage SharePoint Online, open either the SP Management Shell or a simple PowerShell window as an administrator and type the following cmdlet in order to import the SharePoint Online module:

Import-Module Microsoft.Online.SharePoint.Powershell

Then run the following cmdlet to get the credentials of the account that is needed to access to SharePoint Online:

$cred = get-credential

The above command will open up a PowerShell credential request pop-up as shown in the image below:

PowerShell command Get-Credential














The information provided will be saved in the variable "$cred"

Afterward, run the below cmdlet to access the SharePoint Online Service followed by the url of the SharePoint Online Admin Center:

Connect-SPOService -Url https://office365powershell-admin.sharepoint.com -Credential $cred

The information marked in red above should be replaced by the name of your tenant as described in the image below:

Connection to SharePoint Admin Center







You are now ready to execute PowerShell commands within SharePoint Online Service.

Here is a list of useful commands:

Site Collection cmdlets:
Get-SPOSite (Gets one or more site collections)
New-SPOSite (Creates a new SharePoint Online site collection)
Remove-SPOSite (Move a SharePoint Online site collection to the SharePoint Online recycle bin)
Repair-SPOSite (Checks and repair the site collection and its contents)
Set-SPOSite (Sets or updates one or more properties values for a site collection)
Test-SPOSite (Tests a SharePoint Online site collection)
Upgrade-SPOSite (Starts the upgrade process on a site collection)
Get-SPODeletedSite (Gets all deleted site collections from the recycle bin)
Remove-SPODeletedSite (Removes a SharePoint Online deleted site collection from the recycle bin)
Restore-SPODeletedSite (Restores a SharePoint Online deleted site collection from the recycle bin)

Tenant cmdlets:
Get-SPOTenant (View SharePoint Online company or organization properties)
Get-SPOTenantLogEntry (Gets SharePoint Online company or organization logs)
Set-SPOTenant (Sets properties on the SharePoint Online company or organization)

SharePoint Online Groups and Users cmdlets:
Get-SPOUser (View the SharePoint Online user or security group accounts that match a given search criteria)
Get-SPOSiteGroup (Returns all the groups on the specified site collection)
Get-SPOExternalUser (Gets external users in the tenant)
Set-SPOUser (Sets properties on an existing user)
Set-SPOSiteGroup (Returns all the groups on the specified site collection)
Remove-SPOUser (Delete a user or a security group from a site collection or a group)
Remove-SPOSiteGroup (Delete a SharePoint Online group from a site collection)
New-SPOSiteGroup (Creates a new group in a SharePoint Online collection)

Hope this tutorial will help solve or identify the root cause of issues encountered.


Leaving a review only takes 30 seconds and i appreciate it so much!

No comments: