Usage
m365 spo file roleassignment add [options]
Description
Adds a role assignment to the specified file.
Options
| Option |
Description |
-u, --webUrl <webUrl> |
The URL of the site where the file is located. |
-f, --fileUrl [fileUrl] |
The server-relative URL of the file to which the role assignment will be added. Specify either fileUrl or fileId but not both. |
-i, --fileId [fileId] |
The unique id (GUID) of the file to which the role assignment will be added. Specify either fileUrl or fileId but not both. |
--principalId [principalId] |
The SharePoint principal id. It may be either an user id or group id to which the role assignment will be added. 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 file based on the group name.
m365 spo file roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --fileId "b2307a39-e878-458b-bc90-03bc578531d6" --groupName "saleGroup"
Add the role assignment to the specified file based on the principal id.
m365 spo file roleassignment add --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --fileUrl "/sites/project-x/documents/Test1.docx" --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/
Usage
m365 spo file roleassignment add [options]
Description
Adds a role assignment to the specified file.
Options
-u, --webUrl <webUrl>-f, --fileUrl [fileUrl]fileUrlorfileIdbut not both.-i, --fileId [fileId]fileUrlorfileIdbut not both.--principalId [principalId]upn,groupNameorprincipalIdbut not multiple.--upn [upn]upn,groupNameorprincipalIdbut not multiple.--groupName [groupName]upn,groupNameorprincipalIdbut not multiple.--roleDefinitionId [roleDefinitionId]roleDefinitionIdorroleDefinitionNamebut not both.--roleDefinitionName [roleDefinitionName]roleDefinitionIdorroleDefinitionNamebut not both.Examples
Add the role assignment to the specified file based on the group name.
Add the role assignment to the specified file based on the principal id.
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/