I am trying to use the following cmdlet in the pnp module on O365 and one of the parameters for the cmdlet is -identity

-Identity The ID of the listitem, or actual ListItem object

Type:   ListItemPipeBind  
Position:   Named  
Accept pipeline input:  True 
Accept wildcard characters: False

The parameter says the ID of the listitem or the listitem object, I am trying to put the name instead of the ID

So changing -identity from

Set-PnPListItemPermission -List 'Test' -Identity 1  -User '[email protected]' -AddRole 'Contribute' -ClearExisting


Set-PnPListItemPermission -List 'Test' -Identity "TestFolder"  -User '[email protected]' -AddRole 'Contribute' -ClearExisting

The script runs on both occasions with no errors but the permission is only changed when -identity is the ID, am I missing something here?

enter image description here


1 Answer 1


By list item object, it means passing the Microsoft.SharePoint.Client.ListItem object.

You are currently passing string which will not work.

You need to use Get-PnPListItem to get the list item and then pass it to the Set-PnPListItemPermission command.

To do that, you can use it as below:

$listItem = Get-PnPListItem -List 'Test' -Id 1

or passing CAML query, something like

$listItem = Get-PnPListItem -List 'Test' -Query "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>TestFolder</Value></Eq></Where></Query></View>"

And then

Set-PnPListItemPermission -List 'Test' -Identity $listItem  -User '[email protected]' -AddRole 'Contribute' -ClearExisting

Reference - Get-PnPListItem

  • Thank you very much - I tried had tried $listItem = Get-PnPListItem -List 'Test' -Query "<View><Query><Where><Eq><FieldRef Name='Title'/><Value Type='Text'>TestFolder</Value></Eq></Where></Query></View>" | select ID at an earlier point in time but your answer was perfect
    – Jamie_lee
    Feb 2, 2018 at 10:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.