Every now and then I stumble upon a hidden gem in SharePoint. This time around, it happened after I was asked to retrieve a list of all documents on a specific SharePoint site where a given user was the Author. There are no easy way, in SharePoint out-of-the-box to obtain information about who the author is for a given document stored in SharePoint. However, if you go and add a new column to a Document Library and name that column _Author using Single Line of Text as the data type, you can now expose information about the author of the documents that are contained in that library. New documents added to the library will now see their _Author property automatically filled up with information. Please note however, that documents that are already in the document library will need to have their properties updated in order for this value to show up.
Figure 1 below shows the scenario where the document library was created, the document Empty Learning Plan.docx was uploaded, and only then was the _Author field created, which is why its author value is empty. The second document, named CSS Priorities.docx was uploaded to the library after the _Author field had been added, and therefore has its value filled.
Figure 1 – Two documents in a library, one showing the author of the document, the other has the author value empty
If we wish to add the Author’s info to the second document, all we have to do is edit its properties. As soon as we hit the edit form of the document, we see that its _Author property is populated (see Figure 2 below).
Figure 2 – Author property pre-poluated upon modifying items
Automating the Value’s Population
Alright, so most of you reading this blog post will be wanting to include this cool functionality to an existing library, and therefore can’t afford to have to go and edit the properties of every single document to get their _Author value. So what is the solution? Well you know me, so I went crazy and developped the following PowerShell script for you to run on your server to automate the field’s value population. Please note however, that this will update the last modified user and last modified date of all records in the list. The PowerShell script below will prompt you to specify the URL of the web site where the library is located as well as specify the name of the library for which you wish to update the _Author information. Note that if your library requires your documents to be checked out before being edited, that you will need to check them out first. Enjoy!