How to Get SharePoint Online Site Details Using PowerShell?

Do you need to get SharePoint site details using PowerShell? In this tutorial, I will explain how to get SharePoint Online site details using PowerShell (SharePoint management shell) and also using PnP PowerShell.

By using PowerShell, we can get various site properties such as: site URLs, owners, storage usage, templates, creation dates, sharing settings, and more.

1. Using SharePoint Online Management Shell

We can use the SharePoint Online management shell to get various SharePoint site properties.

The first step is to install the SharePoint Online Management Shell, which provides the cmdlets required to manage SharePoint Online via PowerShell.

If you haven’t installed the module yet, open PowerShell as Administrator and run:

Install-Module -Name Microsoft.Online.SharePoint.PowerShell -Force

Then we need to connect to the SharePoint Online tenant to work with the cmdlets.

To connect to your SharePoint Online tenant, use the below cmdlet:

Connect-SPOService -Url "https://yourtenant-admin.sharepoint.com"

Here is an example:

Connect-SPOService -Url "https://szg52-admin.sharepoint.com"

You’ll be prompted to enter your admin credentials. If your organization uses MFA (Multi-Factor Authentication), you’ll go through the MFA process as well.

Check out Change a SharePoint Site URL Using PnP PowerShell

Get All SharePoint Online Sites

To get the SharePoint Online site properties, you can use the Get-SPOSite cmdlet. Here is an example:

Get-SPOSite

By default, this will return a limited number of sites—typically up to 200. To list every site in the tenant:

Get-SPOSite -Limit ALL

This produces a list of all site collections you have access to.

Display All Site Properties

To get all available site properties for each SharePoint site:

Get-SPOSite -Limit All | Select-Object *

This will output a large list of properties, such as:

  • URL
  • Owner
  • Storage Quota
  • Storage Used
  • Template
  • Last Content Modified Date
  • Sharing Capability
  • Lock State
  • Creation Date

Filter SharePoint Sites by Template

By using the -Template parameter, we can also filter SharePoint sites by template.

If you only want team sites then you can use the below cmdlet.

Get-SPOSite -Template "GROUP#0" -Limit All | Select URL, Owner, Template

Filter SharePoint Online Sites by Storage Usage

To find sites using more than 5000 MB of storage:

Get-SPOSite -Limit All | Where-Object { $_.StorageUsageCurrent -gt 5000 } | 
Select URL, StorageUsageCurrent, StorageQuota

Read Get SharePoint Site ID using PnP PowerShell

Filter SharePoint Sites By Owner

Many times, you might need to filter SharePoint sites by owner.

If you want to find SharePoint sites by owner, then you can use the below PowerShell script:

$userUPN = "bijay@szg52.onmicrosoft.com"
Get-SPOSite -Limit ALL | Where-Object {$_.Owner -eq $userUPN} | Select Url, Owner

Retrieve Specific SharePoint Site Details

To view detailed information about a particular site, supply the site’s URL:

Get-SPOSite -Identity https://szg52.sharepoint.com/sites/Finance | Format-List

This outputs dozens of properties—URL, site owner, storage quota, sharing settings, last modified date, and more—making it easy to audit and troubleshoot individual sites.

Export SharePoint Sites to CSV

If you want to export the SharePoint sites to CSV, then you can use the following cmdlet:

Get-SPOSite -Limit All | 
Select URL, Owner, Template, StorageUsageCurrent, StorageQuota, LastContentModifiedDate |
Export-Csv -Path "C:\Reports\SPOSitesReport.csv" -NoTypeInformation

This will create a CSV file you can open in Excel.

Check out Get SharePoint Site Creation Date using PnP PowerShell

2. Using PnP PowerShell

You can also use PnP PowerShell to get SharePoint Online site details.

While Get-SPOSite is powerful, PnP PowerShell can retrieve even more details, such as site classifications, hub site associations, and more.

If you have not installed PnP PowerShell, you can run the following cmdlet to install it:

Install-Module -Name PnP.PowerShell

Then you can use the following cmdlet to

Connect-PnPOnline -Url "https://szg52.sharepoint.com" -Interactive

If it did not work, you can use the below cmdlet.

Connect-PnPOnline -Url "https://szg52.sharepoint.com/sites/spfxtraining" -ClientId "a03427ad-e13d-4e1c-rfg9-ac35ed4e42e" -Interactive

To get the SharePoint Online site details, you can use the below PnP PowerShell cmdlet.

Get-PnPTenantSite | Select Url, Title, StorageUsage, Owner | Format-Table

Here is the exact output in the screenshot below:

get sharepoint online site details powershell

Or you can also use the below cmdlet.

Get-PnPTenantSite -IncludeOneDriveSites $false | 
Select Url, Owner, Template, StorageUsage, StorageQuota, TimeZoneId, HubSiteId

To get detailed information for a specific SharePoint site, run the following cmdlet.

Get-PnPTenantSite -Identity https://szg52.sharepoint.com/sites/HR | Format-List

Read Download Files from SharePoint Document Library Using PnP PowerShell

Real Example

Here is an example that needs to check all SharePoint sites for:

  • Last modified date older than 180 days
  • Storage usage over 80%
  • External sharing enabled

Below is the complete PowerShell script:

# Get all site details
$sites = Get-SPOSite -Limit All

# Filter and check compliance
$report = foreach ($site in $sites) {
    $percentUsed = ($site.StorageUsageCurrent / $site.StorageQuota) * 100
    if ($percentUsed -gt 80 -or $site.SharingCapability -ne "Disabled" -or $site.LastContentModifiedDate -lt (Get-Date).AddDays(-180)) {
        [PSCustomObject]@{
            URL                       = $site.URL
            Owner                     = $site.Owner
            StorageUsageMB            = $site.StorageUsageCurrent
            StorageQuotaMB            = $site.StorageQuota
            PercentUsed               = "{0:N2}" -f $percentUsed
            SharingCapability         = $site.SharingCapability
            LastContentModifiedDate   = $site.LastContentModifiedDate
        }
    }
}

# Export to CSV
$report | Export-Csv -Path "C:\Reports\SPOSiteComplianceReport.csv" -NoTypeInformation

Conclusion

In this tutorial, I explained how to get SharePoint site details using PowerShell and PnP PowerShell. Do let me know if you still have any questions.

You may also like the following tutorials:

Leave a Comment

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

FREE Download an eBook that contains 100 PowerShell cmdlets with complete script and examples.