Forum Discussion

Arioule's avatar
Arioule
Copper Contributor
Jan 19, 2021

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 "Contribute"

However the user running the script/command was also added with Full Control permissions.

 

Is there any other way to remove all existing permissions for a list item using PnP Powershell ?

 

Thanks

  • Arioule 

     

    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"

     

     

    ReferenceSet-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 

     

    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"

     

     

    ReferenceSet-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.

Resources