Saturday, February 27, 2016

SharePoint Online: Get All Site Collections using PowerShell

If you want to get a list of SharePoint online site collections, you can go to SharePoint admin center (Typically at:

Get All Site Collections in SharePoint online using PowerShell

This gets you the list of all site collections in SharePoint Online. Lets see the SharePoint online PowerShell to get all site collections.

PowerShell Script to get all Site Collections in SharePoint Online:
Lets use PowerShell to get a list of Site collections from SharePoint online.
#Load SharePoint Online Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Variables for Processing
$AdminUrl = ""
$UserName= ""
$Password = "Password goes here"
#Setup Credentials to connect
$SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force
$Credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword

#connect to the service
Connect-SPOService -Url $AdminUrl -Credential $Credentials

#Get All Site Collections
$SiteColl = Get-SPOSite 

#Iterate through each site collection
foreach($Site in $SiteColl)
    Write-host $Site.Url
Similar to On-Premises SharePoint Management Shell, You can also use "SharePoint Online Management Shell" to connect to Office 365, SharePoint online sites!
Import-Module Microsoft.Online.Sharepoint.PowerShell -DisableNameChecking


$Credential = Get-credential 
Connect-SPOService -url $AdminSiteURL -Credential $Credential 

Get-SPOSite -Detailed | Format-Table Url, Template, StorageUsageCurrent, StorageQuota, LastContentModifiedDate -AutoSize 

Export All Site Collection inventory to CSV:
$Credential = Get-credential
Connect-SPOService -url "" -Credential $Credential
Get-SPOSite -Detailed | Export-CSV -LiteralPath C:\SitesInventory.csv -NoTypeInformation

Read more here: How to Use PowerShell with SharePoint Online

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...