Saturday, October 5, 2019

Last modified date of List/Library in SharePoint using PowerShell

Add-PSSnapin Microsoft.Sharepoint.Powershell
[Microsoft.SharePoint.SPSecurity]::RunWithElevatedPrivileges({
$Output="C:\users\ajtech\desktop\Output.csv";
$webApplicationURL = "http://2010.ajtech.com/"
$webApp = Get-SPWebApplication $webApplicationURL

if($webApp -ne $null)
{
  Write-Host "Web Application : " + $webApp.Name ;

  foreach($siteColl in $webApp.Sites)
    {
     if($siteColl -ne $null)
      {
         Write-Host "Site Collection : " + $siteColl.Url ;
         foreach($subWeb in $siteColl.AllWebs)
          {
            if($subWeb -ne $null)
              {
                #Print each Subsite;
                Write-Host $subWeb.Url ;
                 Write-Host $subWeb ;
$list = $subweb.Lists
write-Host " List last modified date is .. " + $list.LastModifiedDate + " And Modified By " + $List.Author
                 $subWeb.Dispose()
              }
           else
              {
                Echo $subWeb "does not exist"
              }
          }
            $siteColl.Dispose()
       }
     else
         {
            Echo $siteColl "does not exist"
         }
     }
} else
     {       Echo $webApplicationURL "does not exist, check the WebApplication name"
     }Remove-PsSnapin Microsoft.SharePoint.PowerShell
Echo Finish
}); 

No comments:

Post a Comment