kwizcom banner advertisement

Get All SharePoint Online Site Collections Inventory using PowerShell

Requirement: Get all site collections inventory in SharePoint Online using PowerShell

PowerShell to Get All SharePoint Online Site Collections Inventory:
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking

#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput="C:\Temp\SPOStorage.csv"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL –Credential $Cred

#Get All site collections
$SiteCollections = Get-SPOSite -Limit All
Write-Host "Total Number of Site collections Found:"$SiteCollections.count -f Yellow

#Array to store Result
$ResultSet = @()

#Loop through each site collection and retrieve details
Foreach ($Site in $SiteCollections)
{
    Write-Host "Processing Site Collection :"$Site.URL -f Yellow

    #Get site collection details    
    $Result = new-object PSObject
    $Result | add-member -membertype NoteProperty -name "Title" -Value $Site.Title
    $Result | add-member -membertype NoteProperty -name "Url" -Value $Site.Url
    $Result | add-member -membertype NoteProperty -name "LastContentModifiedDate" -Value $Site.LastContentModifiedDate
    $Result | add-member -membertype NoteProperty -name "Status" -Value $Site.Status
    $Result | add-member -membertype NoteProperty -name "LocaleId" -Value $Site.LocaleId
    $Result | add-member -membertype NoteProperty -name "LockState" -Value $Site.LockState
    $Result | add-member -membertype NoteProperty -name "StorageQuota" -Value $Site.StorageQuota
    $Result | add-member -membertype NoteProperty -name "StorageQuotaWarningLevel" -Value $Site.StorageQuotaWarningLevel
    $Result | add-member -membertype NoteProperty -name "Used" -Value $Site.StorageUsageCurrent
    $Result | add-member -membertype NoteProperty -name "CompatibilityLevel" -Value $Site.CompatibilityLevel
    $Result | add-member -membertype NoteProperty -name "Template" -Value $Site.Template
    $Result | add-member -membertype NoteProperty -name "SharingCapability" -Value $Site.SharingCapability
    
    $ResultSet += $Result
}  
 
#Export Result to csv file
$ResultSet |  Export-Csv $ReportOutput -notypeinformation
 
Write-Host "Site Quota Report Generated Successfully!" -f Green   

and the result:

sharepoint online get all site collections powershell

Here is the List of all properties you can retrieve from a SharePoint Online site collection:
  • LastContentModifiedDate
  • Status
  • ResourceUsageCurrent
  • ResourceUsageAverage
  • StorageUsageCurrent
  • LockIssue
  • WebsCount
  • CompatibilityLevel
  • DisableSharingForNonOwnersStatus
  • Url
  • LocaleId
  • LockState
  • Owner
  • StorageQuota
  • StorageQuotaWarningLevel
  • ResourceQuota
  • ResourceQuotaWarningLevel
  • Template
  • Title
  • AllowSelfServiceUpgrade
  • DenyAddAndCustomizePages
  • PWAEnabled
  • SharingCapability
  • SandboxedCodeActivationCapability
  • DisableCompanyWideSharingLinks
  • DisableAppViews
  • DisableFlows
  • StorageQuotaType
  • SharingDomainRestrictionMode
  • SharingAllowedDomainList
  • SharingBlockedDomainList
Use this PowerShell script in SharePoint Online Management Shell to get all available properties of a SharePoint Online site collection:
#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput="C:\Temp\SPOStorage.csv"

#Get Credentials to connect to SharePoint Admin Center
$Cred = Get-Credential

#Connect to SharePoint Online Admin Center
Connect-SPOService -Url $AdminSiteURL –Credential $Cred

#Get all Site collections details and Export to CSV
Get-SPOSite -Limit ALL -Detailed | Export-Csv -Path $ReportOutput -NoTypeInformation

My Another post on getting all site collections using PowerShell in SharePoint Online: Get All Site Collections using PowerShell
Get All SharePoint Online Site Collections Inventory using PowerShell Get All SharePoint Online Site Collections Inventory using PowerShell Reviewed by Salaudeen Rajack on 12:37 PM Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.