Forum Discussion

Nigel Price's avatar
Nigel Price
Iron Contributor
Jun 15, 2017

How Do I break inheritance on a List or web using PnP Powershell

Hi

 

How do I break inheritance on a list or web using PnP PowerShell ?

 

Must be with PowerShell running on a client NOT on the SharePoint server.

 

Thanks

 

Nigel

  • Hi Nigel Price

     

    I've got a list called Testlist in the root of my site collection that I connected to with ConnectPnPOnline.

     

    The following 6 lines now do what you need:

     

    $web = Get-PnPWeb -Identity "/" 
    $spoList= Get-PnPList "Testlist" -Web $web 
    $spoList.BreakRoleInheritance($true, $true)
    $spoList.Update()
    
    $spoList.Context.Load($spoList)
    $spoList.Context.ExecuteQuery()

     

  • Hi Nigel Price

     

    I've got a list called Testlist in the root of my site collection that I connected to with ConnectPnPOnline.

     

    The following 6 lines now do what you need:

     

    $web = Get-PnPWeb -Identity "/" 
    $spoList= Get-PnPList "Testlist" -Web $web 
    $spoList.BreakRoleInheritance($true, $true)
    $spoList.Update()
    
    $spoList.Context.Load($spoList)
    $spoList.Context.ExecuteQuery()

     

    • bakas1275's avatar
      bakas1275
      Copper Contributor
      This works for web as well
      $web.BreakRoleInheritance($true, $false)
      $web.Update()
      $web.Context.Load($web)
      $web.Context.ExecuteQuery()

Resources