pnp / cli-microsoft365

Manage Microsoft 365 and SharePoint Framework projects on any platform
https://aka.ms/cli-m365
MIT License
916 stars 324 forks source link

Change the function to get the site ID in `spo site admin` commands with the `--asAdmin` parameter. #6443

Open mkm17 opened 5 hours ago

mkm17 commented 5 hours ago

Priority

(Medium) I'm annoyed but I'll live

Description

Hi, when I tested the spo site admin list command with --asAdmin parameter for a script sample, I saw that there is an issue to get site id using the current method used. Currently it returns error when current user have SP admin permissions but it does not have access to a site.

Commands affected:

spo site admin add spo site admin remove spo site admin list

Steps to reproduce

Remove all existing permissions of the current user from the SharePoint site. Run spo site admin list --asAdmin.

Expected results

It should get a list of admins, even if the user does not have any permission to the site.

Actual results

It gives an error when the user does not have access to a site.

Diagnostics

No response

CLI for Microsoft 365 version

10.0.0

nodejs version

18.20.2

Operating system (environment)

Windows

Shell

PowerShell

cli doctor

No response

Additional Info

The fix can be done by replacing spo.getSiteId with spo.getSiteAdminPropertiesByUrl as proposed by @milanholemans in one of the commands.

Please assign this task to me.

milanholemans commented 5 hours ago

Great suggestion, @mkm17. Since the commands are currently working but just require an extra permission scope, I suggest that we categorize this as an enhancement instead of a bug.