pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
687 stars 351 forks source link

[BUG] Export-PnPListToSiteTemplate doesn't export token for default RoleDefinitions #3967

Open waaromikniet opened 6 months ago

waaromikniet commented 6 months ago

Reporting an Issue or Missing Feature

When I export a list with custom permissions no token for default RoleDefinition is set for the RoleDefinition attribute

          <pnp:Security>
            <pnp:BreakRoleInheritance CopyRoleAssignments="false" ClearSubscopes="false">
              <pnp:RoleAssignment Principal="{associatedownergroupid}" RoleDefinition="Lezen" />
            </pnp:BreakRoleInheritance>
          </pnp:Security>

Expected behavior

When I export the list I want to get the token for default RoleDefinition. See below

          <pnp:Security>
            <pnp:BreakRoleInheritance CopyRoleAssignments="false" ClearSubscopes="false">
              <pnp:RoleAssignment Principal="{associatedownergroupid}" RoleDefinition="{roledefinition:Reader}" />
            </pnp:BreakRoleInheritance>
          </pnp:Security>

Actual behavior

When I export a list with custom permissions no token for default RoleDefinition is set for the RoleDefinition attribute

          <pnp:Security>
            <pnp:BreakRoleInheritance CopyRoleAssignments="false" ClearSubscopes="false">
              <pnp:RoleAssignment Principal="{associatedownergroupid}" RoleDefinition="Lezen" />
            </pnp:BreakRoleInheritance>
          </pnp:Security>

Steps to reproduce behavior

Run the Export-PnPListToSiteTemplate cmdlet on a list with custom permissions with built in RoleDefinition

What is the version of the Cmdlet module you are running?

2.4.0

Which operating system/environment are you running PnP PowerShell on?

markgort86 commented 6 months ago

I reproduced this behaviour, but it's not clear to me why this is not working as expected. I created a new SharePoint Online list, broke the permissions inheritance on it. Run the Export-PnPListToSiteTemplate cmdlet and below is the response i get on the screen.

<pnp:Security>
  <pnp:BreakRoleInheritance CopyRoleAssignments="false" ClearSubscopes="false">
      <pnp:RoleAssignment Principal="{associatedownergroupid}" RoleDefinition="Full Control" />
      <pnp:RoleAssignment Principal="{associatedvisitorgroupid}" RoleDefinition="Read" />
      <pnp:RoleAssignment Principal="{associatedmembergroupid}" RoleDefinition="Edit" />
  </pnp:BreakRoleInheritance>
</pnp:Security>

I also created a custom permission level named "CustomPermissionLevel" and the response is the following:

<pnp:Security>
  <pnp:BreakRoleInheritance CopyRoleAssignments="false" ClearSubscopes="false">
    <pnp:RoleAssignment Principal="{associatedownergroupid}" RoleDefinition="Full Control" />
    <pnp:RoleAssignment Principal="{associatedvisitorgroupid}" RoleDefinition="CustomPermissionLevel" />
    <pnp:RoleAssignment Principal="{associatedmembergroupid}" RoleDefinition="Edit" />
  </pnp:BreakRoleInheritance>
</pnp:Security>

Is it possible to provide some more details what you are trying to do?

waaromikniet commented 5 months ago

I want to be able to run my template on a English site. The definition "Lezen" is not recognized then because its Dutch