How to Get SharePoint Site Creation Date using PnP PowerShell?

Recently, one of my clients asked me to get the creation date of a SharePoint Online site. I used PnP PowerShell for this, which is easy to use and to work with SharePoint sites. In this tutorial, I will show you how to get SharePoint site creation date using PnP PowerShell.

Get SharePoint Site Creation Date using PnP PowerShell

If you have access to the SharePoint Online admin center, then you can check the creation date of the SharePoint site from the Active Sites tab.

Otherwise, PnP PowerShell is another best option to get the SharePoint site creation date.

Here is the complete PowerShell script.

# Define the site collection URL
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"

# Connect to SharePoint Online
Connect-PnPOnline -Url $siteUrl -Interactive

# Retrieve the root web of the site collection
$web = Get-PnPWeb -Includes Created

# Retrieve the site collection creation date
$creationDate = $web.Created

# Display the creation date
Write-Host "The site collection was created on:" $creationDate

I executed the above PnP PowerShell script using VS code; you can see here it displays the creation of the SharePoint Online site.

Get SharePoint Site Creation Date using PnP PowerShell

Here, I have used the Get-PnPWeb PnP PowerShell cmdlet with the -Includes Created parameter to get the creation date of the root web.

If you want to reuse the code, then you can create a function like below:

function Get-SPOCreationDate {
    param (
        [Parameter(Mandatory=$true)]
        [string]$SiteUrl
    )

    try {
        # Connect to SharePoint Online
        Connect-PnPOnline -Url $SiteUrl -Interactive

        # Retrieve the root web of the site collection
        $web = Get-PnPWeb -Includes Created

        # Retrieve the site collection creation date
        $creationDate = $web.Created

        # Display the creation date
        Write-Host "The site collection was created on:" $creationDate
    }
    catch {
        Write-Host "An error occurred:" $_.Exception.Message
    }
}

# Example Usage
$siteUrl = "https://szg52.sharepoint.com/sites/PowerShellFAQs"
Get-SPOCreationDate -SiteUrl $siteUrl

Every time the user passes the SharePoint site URL, the site creation date will be displayed.

I hope this tutorial helps you and you got to know now how to get the SharePoint Online site creation date using PnP PowerShell. Still have questions, feel free to leave a comment below.

You may like the following tutorials:

100 PowerShell cmdlets download free

100 POWERSHELL CMDLETS E-BOOK

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