cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

New command: 🔐 spo folder roleinheritance reset

Open Adam-it opened this issue 3 years ago • 5 comments

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.

Adam-it avatar Aug 21 '22 09:08 Adam-it

@pnp/cli-for-microsoft-365-maintainers and another one on the permission management list 😉. Any comments on this one ?

Adam-it avatar Aug 21 '22 09:08 Adam-it

Looks great @Adam-it

martinlingstuyl avatar Aug 21 '22 15:08 martinlingstuyl

Looks great @Adam-it

Ok, opening it up

Adam-it avatar Aug 21 '22 16:08 Adam-it

Can I work on this?

nanddeepn avatar Sep 13 '22 14:09 nanddeepn

Sure @nanddeepn

Thank you for contributing! 👏

milanholemans avatar Sep 13 '22 14:09 milanholemans

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 avatar Oct 01 '22 19:10 nanddeepn

@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

Adam-it avatar Oct 01 '22 19:10 Adam-it

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.

nanddeepn avatar Oct 02 '22 04:10 nanddeepn

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

Adam-it avatar Oct 02 '22 08:10 Adam-it