Question

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 'Test@test.com' -AddRole 'Contribute' -ClearExisting

To

Set-PnPListItemPermission -List 'Test' -Identity "TestFolder"  -User 'Test@test.com' -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

https://docs.microsoft.com/en-us/powershell/module/sharepoint-pnp/set-pnplistitempermission?view=sharepoint-ps

Était-ce utile?

La solution

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 'Test@test.com' -AddRole 'Contribute' -ClearExisting

Reference - Get-PnPListItem

Licencié sous: CC-BY-SA avec attribution
Non affilié à sharepoint.stackexchange
scroll top