Set Item Level Permissions in SharePoint list using PnP PowerShell

In 2 proven steps set Item Level Permissions in SharePoint list

No comments

 22,322 total views,  1 views today

Find related required permissions f...
Find related required permissions for a permission in Salesforce

This post will teach us how to set Item Level Permissions in SharePoint list using the list settings page as well as PnP PowerShell. And also, we can learn how to set item level permission inthe  SharePoint list using Power Automate using our previous article – Power Automate[Detailed]: set item level permissions in SharePoint online step by step with HTTP request.

Set Item Level Permissions in the SharePoint list step by step

Go to the list setting page -> Click on Advanced Settings

Set Item Level Permissions in SharePoint list step by step

Item-Level Permissions: By default settings will be as below:

  • Read all items
  • Create and edit all items

Set Item Level Permissions in SharePoint list - Enable

Change the above Item-Level Permissions settings as below:

  • Read items that were created by the user.
  • Create items and edit items that were created by the user.

Create items and edit items that were created by the user - set Item Level Permissions in SharePoint list

Notes:

  • Item level permission setting is not available both in the Document Library and Issue Tracking list, so you need to ensure your list is not a type of these two. Using the PowerShell script also we can enable item-level permission for the list, refer to the below PowerShell script.
  • Check the permission level of the user on the site and list level. The Item-level permissions configuration is available to those users who have at least design level permission at the site and list level.

Set Item Level Permissions in SharePoint list using PnP PowerShell -SharePoint List Item level permissions missing

Using the below PnP PowerShell script we can set item-level permissions in the SharePoint Online list:


####The below script is used to enable the item-level permission configuration in the SharePoint Online list#############

cls

$PSshell = Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorVariable err -ErrorAction SilentlyContinue
if($PSshell -eq $null)
{
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}

$fileName = "LogEnableItemLevelPermissioninSPOList"

#'yyyyMMddhhmm yyyyMMdd
$enddate = (Get-Date).tostring("yyyyMMddhhmmss")
#$filename = $enddate + '_VMReport.doc'
$logFileName = $fileName +"_"+ $enddate+"_Log.txt"
$invocation = (Get-Variable MyInvocation).Value
$directoryPath = Split-Path $invocation.MyCommand.Path

$directoryPathForLog=$directoryPath+"\"+"LogFiles"
if(!(Test-Path -path $directoryPathForLog))
{
New-Item -ItemType directory -Path $directoryPathForLog
#Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
#$logPath = $directoryPath + "\" + $logFileName

$logPath = $directoryPathForLog + "\" + $logFileName

$isLogFileCreated = $False

function Write-Log([string]$logMsg)
{
if(!$isLogFileCreated){
Write-Host "Creating Log File..."
if(!(Test-Path -path $directoryPath))
{
Write-Host "Please Provide Proper Log Path" -ForegroundColor Red
}
else
{
$script:isLogFileCreated = $True
Write-Host "Log File ($logFileName) Created..."
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}
else
{
[string]$logMessage = [System.String]::Format("[$(Get-Date)] - {0}", $logMsg)
Add-Content -Path $logPath -Value $logMessage
}
}

#Paramaters area
$siteURL="https://globalsharepoint2020.sharepoint.com/" #Your Site URL should be here.
$userName = "YourSPOUser@YourSPOTenant.sharepoint.com" #Your user name should be here.
$passWord = "YourSPOPassword" #Your password should be here.
$encPassWord = convertto-securestring -String $passWord -AsPlainText -Force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $userName, $encPassWord
$listName="Employee" #Your list name should be here.
#Paramaters area - Ends

try
{

Connect-PnPOnline -Url $siteURL -Credentials $cred

#Get the List
$objList = Get-PnPList $listName -Includes ReadSecurity

#Set List Item-Security
$objList.ReadSecurity = 2 #This indicates - Read items that were created by the user.
$objList.WriteSecurity = 2 #This indicates - Create items and edit items that were created by the user.
$objList.Update()
Invoke-PnPQuery

}
catch
{

$ErrorMessage = $_.Exception.Message +"in setting item-level permission in SPO list!:"
Write-Host $ErrorMessage -BackgroundColor Red
Write-Log $ErrorMessage

}

Note:

  • With the administrator account above PnP PowerShell script should be executed.

Summary: Set Item Level Permissions in the SharePoint list

Thus, in this article we have learned the below:

  • How to enable Item-Level Permissions in SharePoint Custom list.
  • How to use Item-Level Permissions in SharePoint list.
  • Item-Level Permissions default settings.

See Also: SharePoint Online Tutorials

You may also like the below SharePoint Online tutorials:

PDF Download Image

Download SharePoint Online & Office 365 Administration eBook

Buy the premium version of SharePoint Online & Office 365 administration eBook from here:



Buy SharePoint Online & Office 365 Administration eBook


 

Get the free demo PDF eBook from here:

FREE DOWNLOAD

Send download link to:

Subscribe to get exclusive content and recommendations every month. You can unsubscribe anytime.

About Post Author

Do you have a better solution or question on this topic? Please leave a comment