Saturday, October 5, 2019

List of Unused Sites in SharePoint using PowerShell

$outputPath = “C:\unread\UnusedSites.doc”

$lastDate=Read-Host “Last Accessed Date (in format mm/dd/yyyy)”

$gc = Start-SPAssignment

$site=$gc | get-spsite -Identity http://2010.ajtech.com



foreach($web in $site.AllWebs)
{

$siteusage = $site.Usage.Storage/1MB

$Hits = $site.Usage.Hits

$Created = [datetime]$web.Created



if ($web.LastItemModifiedDate -lt $lastDate)

{
Write-Host -f Red “Site is old…” + $Web.Title +"Site Usage is ..." $siteusage + "Created Date is ..." $Created

Add-Content -Path $outputPath -Value “$($web.url),
$($web.LastItemModifiedDate),$($web.Author)”

}

else
{
Write-Host -f Green “Site: [" + $web.Title + "] Last Modified Date: ” + $web.LastItemModifiedDate + $web.url + $siteusage + $Created

Add-Content -Path $outputPath –Value “$($web.url),
$($web.LastItemModifiedDate),$($web.Author)”
}
}



Stop-SPAssignment $gc

No comments:

Post a Comment