New command: 🔐 spo listitem roleassignment remove
Usage
m365 spo listitem roleassignment remove [options]
Description
removes a role assignment to a listitem.
Options
| Option | Description |
|---|---|
-u, --webUrl <webUrl> |
URL of the site where the list is located |
-i, --listId [listId] |
ID of the list. Specify either listId, listTitle or listUrl. |
-t, --listTitle [listTitle] |
Title of the list. Specify either listId, listTitle or listUrl. |
--listUrl [listUrl] |
Relative URL of the list. Specify either listId, listTitle or listUrl. |
--listItemId <listItemId> |
Id of the listitem to remove the role from. |
--principalId [principalId] |
The SharePoint Id of the principal. It may be either a user id or group id to add a role assignment for. Specify either upn, groupName or principalId. |
--upn [upn] |
upn/email of user to assign role to. Specify either upn, groupName or principalId. |
--groupName [groupName] |
The group name of Azure AD or SharePoint group. Specify either upn, groupName or principalId. |
Examples
remove roleassignment from list item in list by title based on group name
m365 spo listitem roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listTitle "someList" --listItemId 1 --groupName "saleGroup"
remove roleassignment from list item in list by title based on principal Id
m365 spo listitem roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listTitle "Events" --listItemId 1 --principalId 2
remove roleassignment from list item in list by url based on principal Id
m365 spo listitem roleassignment remove --webUrl "https://contoso.sharepoint.com/sites/contoso-sales" --listUrl '/sites/contoso-sales/lists/Events' --listItemId 1 --principalId 2
Additional Info
we may use this POST endpoint
/_api/web/lists/getbytitle("SomeList")/items("SomeId")/roleassignments/removeroleassignment(principalid='{SomeGroupOrUserIDHere}')
putting this on hold before we agree on some on the approach here https://github.com/pnp/cli-microsoft365/issues/3540
@pnp/cli-for-microsoft-365-maintainers same here. Very similar to the one already merged. https://github.com/pnp/cli-microsoft365/pull/3567 just different level? anyone has any comments? if not maybe I could take it ?
Looks good to me.
just added the confirmation option to the spec and will be taking this one
@Adam-it, I think we forgot something: when we have listUrl options, the option should support both Server-relative AND web-relative URL's. Just like spo field list.
Do you have that covered? If not: all permission commands should include that. Could you pick that up and include it in your PR's?
@Adam-it, I think we forgot something: when we have
listUrloptions, the option should support both Server-relative AND web-relative URL's. Just likespo field list.Do you have that covered? If not: all permission commands should include that. Could you pick that up and include it in your PR's?
isn't it like covered by the CLI 🤔. If we have the SpoUrl set the CLI should resolve it during execution time 'just like that'
PS C:\Workspace\CLI\cli-microsoft365> m365 spo get
{
"SpoUrl": "https://tenanttocheck.sharepoint.com"
}
PS C:\Workspace\CLI\cli-microsoft365> m365 spo listitem roleassignment remove --webUrl "https://tenanttocheck.sharepoint.com/sites/hr-life" --listTitle "test" --listItemId 1 --groupName "otherGroup"
? Are you sure you want to remove role assignment from listitem 1 from list test from site https://tenanttocheck.sharepoint.com/sites/hr-life? No
PS C:\Workspace\CLI\cli-microsoft365> m365 spo listitem roleassignment remove --webUrl "/sites/hr-life" --listTitle "test" --listItemId 1 --groupName "otherGroup"
? Are you sure you want to remove role assignment from listitem 1 from list test from site https://tenanttocheck.sharepoint.com/sites/hr-life? Yes
PS C:\Workspace\CLI\cli-microsoft365>
anyway isn't like the code to manage listUrl option exactly the same 🤔 for example in the listitem roleassignment remove I have
....
else if (args.options.listUrl) {
const listServerRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
requestUrl += `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
}
and what I see in the spo field list
....
else if (args.options.listUrl) {
const listServerRelativeUrl: string = urlUtil.getServerRelativePath(args.options.webUrl, args.options.listUrl);
listUrl = `GetList('${formatting.encodeQueryParameter(listServerRelativeUrl)}')/`;
}
not actually sure what I should change 😅? Sorry for maybe a stupid question 😅
BTW isn't it handled the same way almost everywhere we have the listUrl option ? should the issue and change be more global then? and also we could add an issue to add the listUrl option to many commands in SPO area/namespace which is does not have this option (I think most don't ☹)
You are right @Adam-it, apparently you can provide both a web relative URL and a server relative URL. Just tested it and both scenarios work. So I guess it is ok this way @martinlingstuyl 😊. Maybe we should clarify this a bit in the docs.
@milanholemans thanks for the double check 👍 sure. I may add a better description in docs and more examples 👍. Usually I tend to write to little in the docs 🤔 Sorry for that. But the copilot is getting there 😝
If it works, it works 😀 in that case: could you update the docs for the commands that are concerned?
will do 👍
BTW we could still open and issue to add the missing listUrl option to all other commands that don't have it and have only listTitle and listId 😉