Saturday, July 30, 2016

Mask or hide created/modified user name from SharePoint list item forms and views using PowerShell

Short and sweet this one. As you probably know, whenever you view a list item in SharePoint, the display form shows the date and time that the item was created and last modified along with the name of the user that performed those operations. An example is shown in the screenshot below:

There may be occasions where the user name should be hidden from view for security or other purposes. This feature is normally used by SharePoint for the “Show user names in survey results” option on surveys, but it can be applied to any other list or document library by setting the ShowUser property of a list to false using the small PowerShell script below:




#Get Web and List objects
$web = Get-SPWeb http://SiteUrl
$list = $web.Lists["List Name"]

#Disable user from appearing in item dialogs
$list.ShowUser = $false
$list.Update()

#Dispose of Web object
$web.Dispose()

Once this script has been run on a list, the item display form looks like this:


Note that this also affects the Modified By and Created By columns in list views:



To restore the user name on the list form again, simply set the ShowUser property back to true.

No comments:

Post a Comment