Hello SharePoint Pals,
Here is an Interesting piece of requirement that I would like to share with you all. Suddenly one of my customers had come up with a requirement , that he would like to know how frequent the SharePoint doucment library is modified and usage analytics of the documents in a document library. The simple and efficient method that I follow is to get Version History for all the documents in a SharePoint Library using PowerShell Commands.
Here is the piece of code provided below.
  1. $Site = Get-SPSite http://mysite/Sample
  2. $Webs = $Site.AllWebs
  3. foreach ($Web in $Webs)
  4. {
  5. foreach ($List in $web.Lists)
  6. {
  7. //Check if the Versioning is enabled or not.
  8. if($List.EnableVersioning)
  9. {
  10. $Item=$List.Items[0]
  11. foreach($Version in $Item.Versions)
  12. {
  13. Write-Host "Documen Library Name:" $List.Title "-" "Document Name:" $Item.Title $Version.VersionLabel
  14. }
  15. }
  16. }
  17. }
  18. $Web.Dispose()
  19. $Site.Dispose()
Happy SharePointing :-)