SharePoint Online: Get Site Collection Created Date using PowerShell

Requirement: Get the 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 creation date of a SharePoint Online site collection, do the following:

  1. Login to SharePoint Admin center >> Expand Sites >> Active Sites.
  2. 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! Make sure you have site collection admin rights before running these scripts.

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 -Interactive

#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
    Connect-PnPOnline -Url $_.URL -Credentials $Credential

    #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
    })
}
#Sort Site Collection - Sort by Creation Date
$SiteInventory | Sort-Object 'Created Date' -Descending

Knowing the creation date of a SharePoint Online site can help manage and audit your SharePoint environment. With these simple steps, you can easily find the creation date of a site using either the user interface or PowerShell.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

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

  • Is there a way of being able to initiate this reporting without being authorized access to said site? I keep receiving 401 unauthorized errors for the vast majority of the site collections despite being an SPO admin.

    Reply
  • Hi,
    I’m facing an issue with the $Web = Get-PnPWeb -Includes Created
    Even if I run the script with the account that has SP admin role assigned, I get the following error:
    Get-PnPWeb : The remote server returned an error: (403) Forbidden.

    This only works if I add that account as site collection admin. Then the “$Web = Get-PnPWeb -Includes Created” runs ok. But adding site collection admin to each site and then remove it, it significantly slows down the script when processing 8000 sites on daily basis.

    Any solution to this?
    Thanks

    Reply
    • Some properties like Site Owner, Site Created date can be retrieved only when you have site collection admin rights to the site. I’d suggest to either add your SharePoint Admin account to all SharePoint Online sites as site collection administrator or Use the Azure AD App ID method.

      Reply
  • 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

Your email address will not be published. Required fields are marked *