Thursday 20 April 2017

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




Note: 

Kindly change URL and List Name where ever required.

1)Mask UserName For Single List

#Get Web and List objects
$web = Get-SPWeb "URL"
$list = $web.Lists["ListName"]

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

#Dispose of Web object
$web.Dispose()

2)Un-Mask UserName For Single List

#Get Web and List objects
$web = Get-SPWeb "URL"
$list = $web.Lists["ListName"]

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

#Dispose of Web object
$web.Dispose()

3)Mask UserName For All List in Sharepoint Web Application

Add-PSSnapin Microsoft.Sharepoint.Powershell
$site = Get-SPSite "URL"
$sitelists = foreach ($web in $site.AllWebs) {
foreach($list in $web.lists){ 
#Disable user from appearing in item dialogs
$list.ShowUser = $false
$list.Update()
 }
}
Remove-PsSnapin Microsoft.SharePoint.PowerShell

4)Un-Mask UserName For All List in Sharepoint Web Application

Add-PSSnapin Microsoft.Sharepoint.Powershell
$site = Get-SPSite "URL"
$sitelists = foreach ($web in $site.AllWebs) {
foreach($list in $web.lists){ 
#Disable user from appearing in item dialogs
$list.ShowUser = $true
$list.Update()
 }
}
Remove-PsSnapin Microsoft.SharePoint.PowerShell

No comments:

Post a Comment