Skip to content

New command: 🔐 spo file roleinheritance break #3593

@Adam-it

Description

@Adam-it

Usage

m365 spo file roleinheritance break [options]

Description

break inheritance of file. Keeping existing permissions is the default behavior.

Options

Option Description
-u, --webUrl <webUrl> URL of the site where the item for which to break role inheritance is located
--fileUrl [fileUrl] The server-relative URL of the file to retrieve. Specify either url or id but not both
-i, --fileId [fileId] The UniqueId (GUID) of the file to retrieve. Specify either url or id but not both
-c, --clearExistingPermissions Set to clear existing roles from the list item
--confirm Don't prompt for confirmation

Examples

Break inheritance of file with id (UniqueId) b2307a39-e878-458b-bc90-03bc578531d6 located in site https://contoso.sharepoint.com/sites/project-x

m365 spo file roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileId "b2307a39-e878-458b-bc90-03bc578531d6"

Break inheritance of file with id (UniqueId) b2307a39-e878-458b-bc90-03bc578531d6 located in site https://contoso.sharepoint.com/sites/project-x with clearing permissions

m365 spo file roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileId "b2307a39-e878-458b-bc90-03bc578531d6" --clearExistingPermissions

Break inheritance of file with server-relative url /sites/project-x/documents/Test1.docx located in site https://contoso.sharepoint.com/sites/project-x

m365 spo file roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileUrl "/sites/project-x/documents/Test1.docx"

Break inheritance of file with server-relative url /sites/project-x/documents/Test1.docx located in site https://contoso.sharepoint.com/sites/project-x with clearing permissions

m365 spo file roleinheritance break --webUrl "https://contoso.sharepoint.com/sites/project-x" --fileUrl "/sites/project-x/documents/Test1.docx" --clearExistingPermissions

Additional Info

I suggest we implement this command as a wrapper around an existing command we have m365 spo listitem roleinheritance break 👉 https://github.com/pnp/cli-microsoft365/blob/main/src/m365/spo/commands/listitem/listitem-roleinheritance-break.ts
that will give the user the possibility to get file by url or id and then we handle it the same as listitem by using the same command that we have for list item with help of using Cli.executeCommandWithOutput. A quite similar approach we may check in the m365 spo group user add command

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions