Forum Discussion
Arioule
Jan 19, 2021Copper Contributor
How to remove all list item permissions using PnP Powershell
Hi, I would like to remove all permissions of a list item using PnP Powershell I have tried this command : Set-PnPListItemPermission -Identity $item.id -User 'user@contoso.com' -AddRole "Contrib...
- Jan 20, 2021
It's normal behavior for the current user to remain in the list item permissions when the inheritance is broken and cleared on a list item to ensure that at least one user still has access.
Try this:
First assign permissions to a user:
Set-PnPListItemPermission -List 'ListName' -Identity 1 -User 'user@contoso.com' -AddRole 'Contribute' -ClearExisting
Then remove permissions of the user running script:
Set-PnPListItemPermission -List 'ListName' -Identity 1 -User "scriptuser@contoso.com" -RemoveRole "Full Control"
Reference: Set-PnPListItemPermission -ClearExisting adds the user running the script with full control
Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
ganeshsanap
Jan 20, 2021MVP
It's normal behavior for the current user to remain in the list item permissions when the inheritance is broken and cleared on a list item to ensure that at least one user still has access.
Try this:
First assign permissions to a user:
Set-PnPListItemPermission -List 'ListName' -Identity 1 -User 'user@contoso.com' -AddRole 'Contribute' -ClearExisting
Then remove permissions of the user running script:
Set-PnPListItemPermission -List 'ListName' -Identity 1 -User "scriptuser@contoso.com" -RemoveRole "Full Control"
Reference: Set-PnPListItemPermission -ClearExisting adds the user running the script with full control
Please click Mark as Best Response if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
Arioule
Jan 20, 2021Copper Contributor
ganeshsanap Thanks for your help.