SharePoint Online: Get Site Collection Created Date using PowerShell

Requirement: Get Site Collection creation date in SharePoint Online

How to Check SharePoint Online Site Creation Date?

If you are looking for a way to get the creation date of a site collection in SharePoint Online, PowerShell is your best bet. This can be useful for reporting or auditing purposes. In this blog post, we will be looking at how you can get the site collection created date in SharePoint Online. Let’s walk through the steps necessary to get the creation date!

To get the created date of a SharePoint Online site collection, do the following:

  • Login to SharePoint Admin center >> Expand Sites >> Active Sites.
  • Now the sites list shows the creation date of the sites in the “Date Created” column (Add it to the view, if it’s not there already!)
    sharepoint online powershell get site collection created date

SharePoint Online: PowerShell to Get Site Creation Date

PowerShell can help to find the SharePoint Online site collection created date:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
 
#Set parameter values
$SiteURL="https://crescent.sharepoint.com/sites/Ops"

Try { 
        #Get Credentials to connect
        $Cred= Get-Credential
        $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = $Credentials
        
        #Get the Web
        $Web = $Ctx.Web
        $Ctx.Load($web)
        $Ctx.ExecuteQuery()

        #sharepoint online powershell get site creation date
        Write-host -f Green "Site Collection Created Date:"$Web.created.toShortDateString()
     }
    Catch {
        write-host -f Red "Error Getting Site Collection Creation Date!" $_.Exception.Message
   }

This PowerShell gets the site collection creation date!

Get Created Date of All SharePoint Online Site Collections in Office 365 Tenant:

Let’s get created date of all site collections in the tenant.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\SharePoint Online Management Shell\Microsoft.Online.SharePoint.PowerShell\Microsoft.SharePoint.Client.Runtime.dll"

#Config Parameters
$AdminSiteURL="https://crescent-admin.sharepoint.com"
$ReportOutput="C:\Temp\SiteCreatedDate.csv"
 
Try {
    #Get Credentials to connect
    $Cred = Get-Credential
    $Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
 
    #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
 
        Try {
            #Get the Root web of the Site collection
            $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($Site.URL)
            $Ctx.Credentials = $Credentials  
            $RootWeb=$Ctx.Web
            $Ctx.Load($RootWeb)
            $Ctx.ExecuteQuery()
            $CreatedDate = $RootWeb.created.toShortDateString()
        }
        Catch {    
            write-host -f Red "`tError Getting Root Web:" $_.Exception.Message
        }

        #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 "CreatedDate" -Value ($CreatedDate)
        $ResultSet += $Result
    }  
    #Export Result to csv file
    $ResultSet |  Export-Csv $ReportOutput -notypeinformation  
    Write-Host "Site Creation Date Report Generated Successfully!" -f Green
}
Catch {    
    write-host -f Red "Error:" $_.Exception.Message
}

PnP PowerShell to Get Site Collection Created Date in SharePoint Online:

Getting the creation date of a site collection in SharePoint Online with PnP PowerShell is pretty easy!

#Config Variable
$SiteURL = "https://crescent.sharepoint.com/Sites/Marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Get the Root Web with "created" property
$Web = Get-PnPWeb -Includes Created

#Get Site Collection Created Date
Write-host "Site Collection Created on:"$Web.Created 

Let’s get all Site collections sort by created date:

#Parameters
$TenantURL =  "https://crescent.sharepoint.com"
 
#Get Credentials to connect
$Credential = Get-Credential
 
#Frame Tenant Admin URL from Tenant URL
$TenantAdminURL = $TenantURL.Insert($TenantURL.IndexOf("."),"-admin")

#Connect to Admin Center
Connect-PnPOnline -Url $TenantAdminURL -Credentials $Credential
 
#Get All Site collections - Filter BOT and MySite Host
$Sites = Get-PnPTenantSite -Filter "Url -like '$TenantURL'"

#Iterate through all sites
$SiteInventory = @()
$Sites | ForEach-Object {
    #Connect to each site collection
    $SiteConn = Connect-PnPOnline -Url $_.URL -Credentials $Credential -ReturnConnection

    #Get the Root Web with "created" property
    $Web = Get-PnPWeb -Includes Created

    #Collect Data
    $SiteInventory += New-Object PSObject -Property  ([Ordered]@{
        "Site Name"  = $Web.Title
        "URL "= $Web.URL
        "Created Date" = $Web.Created
    })

    Disconnect-PnPOnline -Connection $SiteConn
}
#Sort Site Collection - Sort by Creation Date
$SiteInventory | Sort-Object 'Created Date' -Descending

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

10 thoughts on “SharePoint Online: Get Site Collection Created Date using PowerShell

  • Is there any way to change the time zone? In the date created column the time appears to be from a US time zone.

    Reply
  • Does it need admin access to the site?
    In your articles, can you please mention whenever site admin access is needed. It would be very helpful. Thanks.

    Reply
  • How would you get all the SPOsites created within the last month?

    Reply
    • Just use: $SiteInventory | Where {$_.’Created Date’ -gt [DateTime]::Today.AddDays(-30)}

      Reply
  • Hello! I see that some of your scripts “Filter BOT and MySite Host”, which leads me to believe that you may know more about the purpose of the BOT sites. For example, when I run the command Get-SPOSite I have a site that looks like this example: “https://bot19###-002/sites/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

    I’ve had a ticket open with Microsoft for a couple of weeks and I’m not getting any answers! Thanks for any assistance.

    Reply
  • Hi, is there a way to capture the created date of a subsite too?

    Reply
    • Yes, the script actually gets the created date of the “Root Web”, So just enter the $SiteURL variable value to a Subsite URL!

      Reply
  • How can you capture this for all site collections?

    Reply

Leave a Reply