Skip to content

New command: 🔐 spo folder roleassignment add #3703

@Adam-it

Description

@Adam-it

Usage

m365 spo folder roleassignment add [options]

Description

Adds a role assignment to the specified folder.

Options

Option Description
-u, --webUrl <webUrl> The URL of the site where the file is located
-f, --folderUrl <folderUrl> The server- or site-relative URL of the folder.
--principalId [principalId] The SharePoint principal id. It may be either an user id or group id for which the role assignment will be removed. Specify either upn, groupName or principalId but not multiple.
--upn [upn] The upn/email of the user. Specify either upn, groupName or principalId but not multiple.
--groupName [groupName] The Azure AD or SharePoint group name. Specify either upn, groupName or principalId but not multiple.
--roleDefinitionId [roleDefinitionId] ID of the role definition. Specify either roleDefinitionId or roleDefinitionName but not both.
--roleDefinitionName [roleDefinitionName] The name of the role definition. E.g. 'Contribute', 'Read'. Specify either roleDefinitionId or roleDefinitionName but not both

Examples

Add the role assignment to the specified folder based on the group name.

m365 spo folder roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --folderUrl "/Shared Documents"   --groupName "saleGroup"

Add the role assignment to the specified folder based on the principal Id.

m365 spo folder roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales"  --folderUrl "/Shared Documents"  --principalId 2

Additional Info

a very similar command was already developed but on list level, so we may probably use that command code as reference to make it easier to create this one
https://pnp.github.io/cli-microsoft365/cmd/spo/list/list-roleassignment-add/

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions