New command: 🔐 spo folder roleinheritance reset
Usage
m365 spo folder roleinheritance reset [options]
Description
Restores the role inheritance of folder
Options
| Option | Description |
|---|---|
-u, --webUrl <webUrl> |
URL of the site where the file for which to reset role inheritance is located |
-f, --folderUrl <folderUrl> |
The site-relative URL of the folder |
--confirm |
Don't prompt for confirmation |
Examples
Reset inheritance of folder with site-relative url /Shared Documents located in site https://contoso.sharepoint.com/sites/project-x
m365 spo folder roleinheritance reset --webUrl "https://contoso.sharepoint.com/sites/project-x" --folderUrl "/Shared Documents"
Additional Info
we may also reuse command we already have using Cli.executeCommandWithOutput. We may reuse the m365 spo folder get command and the m365 spo listitem roleinheritance reset.
@pnp/cli-for-microsoft-365-maintainers and another one on the permission management list 😉. Any comments on this one ?
Looks great @Adam-it
Looks great @Adam-it
Ok, opening it up
Can I work on this?
Sure @nanddeepn
Thank you for contributing! 👏
Hi @Adam-it @milanholemans @martinlingstuyl
m365 spo folder get command does not return listItemId, listId, or listTitle which can be passed to m365 spo listitem roleinheritance reset command.
If we need to reset the roleinheritance of sub-folder, then we can use
${args.options.webUrl}/_api/web/GetFolderByServerRelativeUrl('${args.options.folderUrl}')/ListItemAllFields/resetroleinheritance
If we need to reset the roleinheritance of list, we already have m365 spo listitem roleinheritance reset and we cannot use it here because always listTitle cannot be same as URL, as we might have spaces in list title and not in URL.
Considering we already have m365 spo listitem roleinheritance reset for resetting roleinheritance of list, should we target this command only for resetting roleinheritance of sub-folders?
Or, please correct me if I am missing anything here. Thank you.
@nanddeepn thanks for the comment.
I agree we should go with GetFolderByServerRelativeUrl 👍
BTW for reseting roleinheritance of list we have m365 spo list roleinheritance reset not listitem
Thank you @Adam-it
GetFolderByServerRelativeUrl does not support resetting the roleinheritance at the list level.
In this case we have 2 options:
Option 1:
If folderUrl is specified as list name, we will call m365 spo list roleinheritance reset internally.
Option 2:
We can have this command spo folder roleinheritance reset only for resetting the roleinheritance of folder inside list/library.
Please suggest.
TBH I was thinking of the second option. The general aim was to target a command which is supposed to do the same as listitem one (as we may also reset folders using listitem one) but in order to make easier to find for the user we thought of creating dedicated file and folder commands which were suppose to do the same as the lisitem one. So I would say reseting the list permissions was never the intention of this command and for this list roleinheritance reset command should be used