Office 365 SharePoint Online Get All Site Collections Using PowerShell

This blog helps you to retrive all Site Collections in SharePoint Online, using PowerShell method.

Steps
  1. Open SharePoint Management Shell.
  2. Copy the code given below and paste it.
  3. Run the code.
  1. ##########################    
  2.   
  3. #Script  : Below Script will Get All Site Collections  in Office 365 SharePoint Online   
  4. #Author  : Gowtham Rajamanickam    
  5. #Date    :16-03-2017  
  6. #Version:1.0    
  7.   
  8. #########################  
  9.  
  10. #Before Run the Scritp you must load the Client Assembly files   
  11.    
  12. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"  
  13. Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"  
  14.     
  15. #Variables for Processing  
  16. $AdminUrl = "https://gowthamr.sharepoint.com/"  
  17. $UserName= "[email protected]"  
  18. $Password = "Enter your Password here"  
  19.     
  20.   
  21. $SecurePassword = $Password | ConvertTo-SecureString -AsPlainText -Force  
  22. $Credentials = New-Object -TypeName System.Management.Automation.PSCredential -argumentlist $UserName, $SecurePassword  
  23.    
  24.   
  25. Connect-SPOService -Url $AdminUrl -Credential $Credentials  
  26.   
  27. $SiteColl = Get-SPOSite  
  28.   
  29. foreach($Site in $SiteColl)  
  30. {  
  31.     Write-host $Site.Url  
  32. }  
Was my blog helpful? Was any relevant content missing? If so, please let us know what's confusing or missing at the bottom of this page.

Thanks for reading my blog.