Wednesday, July 9, 2014

Get SharePoint Site Collection Created Date using PowerShell

Requirement: I had to generate a report for management review on list of site collections created in the past one Month. 

Solution: Get SharePoint Site Collection Created Date using PowerShell! There is no UI to view site creation date in SharePoint! But you can get site creation date in SharePoint using PowerShell as:

Write-host (Get-SPSite "").RootWeb.created

Lets get all sites created in the past one month based on SharePoint site created date using PowerShell:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Get all site collections
$SitesColl = Get-SPSite -Limit All

#Get start date of Last Last Month
$LastMonth= (Get-Date).AddMonths(-1)

#Loop through all sites
ForEach($Site in $SitesColl)
    #Check site creation date
    if($Site.RootWeb.created -gt $LastMonth)
        $CreatedDate = $Site.RootWeb.created.toShortDateString()
        Write-Host "$($Site.RootWeb.url) was created on $($CreatedDate)"
Find all Site collections created today:
Unlike above code, lets use one-liner to find all site collections created today:
Get-SPSite -Limit All | ? { $_.RootWeb.Created -eq[DateTime]::Today} | select Url, @{Name="Created";Expression={$_.RootWeb.Created}}

Find Created date of a Subsite:
Similar code applies for finding a subsite's created date.
Get-SPweb "" | Select @{Name="Created";Expression={$_.Created}}

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...