Saturday, February 27, 2016

SharePoint Online: Get All Site Collections using PowerShell

PowerShell Script to get all Site Collections in 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! 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...