Skip to main content

SYNOPSIS

Builds an inventory report of every SharePoint Online site of the tenant using PnP.PowerShell app-only.

SYNTAX

DESCRIPTION

Get-SPOSiteReport collects the configuration of the SharePoint Online sites: storage quota and usage, site collection administrators, external sharing settings, sensitivity label, default sharing links, conditional access policy and hub site membership. The function connects with PnP.PowerShell in app-only mode (Entra app registration plus a certificate). This is the only reliable way to read site-level data (site collection administrators, site groups, regional settings) across every site of the tenant: the SharePoint Administrator role alone grants access to the admin center, not to the content of each site, so a delegated connection returns Access Denied on Get-PnPSiteCollectionAdmin. An app registration holding the SharePoint Sites.FullControl.All application permission bypasses the site collection admin requirement. Client secrets are not supported by SharePoint for app-only: a certificate is mandatory. Provide it through CertificateThumbprint (Windows certificate store), CertificatePath (.pfx file) or CertificateBase64Encoded (base64 string, handy for Azure Automation or a pipeline variable). The site-level collection runs in parallel (ForEach-Object -Parallel) with one PnP connection per site. Tune the concurrency with ThrottleLimit. PowerShell 7 is required. Optional switches enrich the report:
  • IncludeSiteAdmins adds the full list of site collection administrators of each site.
  • RegionalSettingsDetails adds the time zone, hour format and locale of each site.
  • SharingRightsAdminOrFullControl adds, best effort, the members of the site groups holding Full Control.
  • M365GroupsDetails adds the Microsoft 365 group and Microsoft Teams layer. This layer relies on Exchange Online (Get-UnifiedGroup) and the MicrosoftTeams module (Get-Team), which are NOT covered by the PnP app-only certificate: connect Exchange Online and Microsoft Teams separately beforehand.

EXAMPLES

EXAMPLE 1

Returns every SharePoint Online site of the tenant, including the personal OneDrive sites, using an app-only connection based on a certificate from the Windows certificate store.

EXAMPLE 2

Returns the SharePoint sites without the OneDrive ones and adds the full list of site collection administrators of each site.

EXAMPLE 3

Returns a single site with its regional settings, using a .pfx certificate file.

EXAMPLE 4

Collects the site collection administrators with 12 concurrent connections and exports the results to an Excel file in the user profile directory.

PARAMETERS

-ClientId

(Mandatory) Application (client) ID of the Entra app registration used for the app-only connection.

-Tenant

(Mandatory) Tenant domain name for the PnP connection, for example contoso.onmicrosoft.com. Used by Connect-PnPOnline (it expects the domain, not the tenant GUID).

-CertificateThumbprint

Thumbprint of the certificate located in the current user’s Windows certificate store. Provide exactly one of CertificateThumbprint, CertificatePath or CertificateBase64Encoded.

-CertificatePath

Path to a local .pfx certificate file. Use CertificatePassword when the file is protected. Provide exactly one of CertificateThumbprint, CertificatePath or CertificateBase64Encoded.

-CertificatePassword

(Optional) SecureString password protecting the .pfx file passed to CertificatePath.

-CertificateBase64Encoded

Base64-encoded certificate (with its private key) passed directly to Connect-PnPOnline. Provide exactly one of CertificateThumbprint, CertificatePath or CertificateBase64Encoded.

-AdminUrl

(Optional) URL of the SharePoint admin center, for example https://contoso-admin.sharepoint.com. When omitted, it is derived from the tenant name of the Tenant parameter. Provide it explicitly when Tenant is a vanity domain (for example contoso.com) rather than an onmicrosoft.com domain.

-SiteUrl

(Optional) Restricts the report to a single site collection URL. When omitted, every site of the tenant is processed.

-ExcludeOneDrive

(Optional) Excludes the personal OneDrive sites from the report. Cannot be combined with OnlyOneDrive.

-OnlyOneDrive

(Optional) Restricts the report to the personal OneDrive sites. Cannot be combined with ExcludeOneDrive.

-IncludeSiteAdmins

(Optional) Adds the full list of site collection administrators of each site, resolved with Get-PnPSiteCollectionAdmin. Requires the app-only connection described above.

-RegionalSettingsDetails

(Optional) Adds the regional settings of each site (time zone, hour format, locale), read with Get-PnPWeb. This switch significantly increases the execution time on large tenants.

-SharingRightsAdminOrFullControl

(Optional) Adds, best effort, the members of the site groups holding Full Control permissions. This relies on Get-PnPGroup and Get-PnPGroupPermissions and is marked experimental in PnP mode: the permission level names depend on the site language and are matched against ‘Full Control’.

-M365GroupsDetails

(Optional) Adds the Microsoft 365 group and Microsoft Teams details of the group-connected sites. Requires an active Exchange Online session (Connect-ExchangeOnline) and the MicrosoftTeams module, both connected separately from the PnP app-only certificate. This switch significantly increases the execution time on large tenants.

-ThrottleLimit

(Optional) Maximum number of sites processed concurrently by the parallel site-level collection. Default is 8.

-ExportToExcel

(Optional) If specified, exports the results to an Excel file in the user’s profile directory.

-ExportPath

(Optional) Output directory for the Excel export. Defaults to the user profile.

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

NOTES

https://ps365.clidsys.com/docs/commands/Get-SPOSiteReport