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: https://YOURCOMPANY-admin.sharepoint.com/_layouts/15/online/SiteCollections.aspx).

Get All Site Collections in SharePoint online using PowerShell

This gets you the list of all site collections in SharePoint Online.

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 = "https://crescent-admin.sharepoint.com/"
$UserName= "Salaudeen@crescent.com"
$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! 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.
*Sponsored


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...