cli-microsoft365 icon indicating copy to clipboard operation
cli-microsoft365 copied to clipboard

New command: `m365 spo site admin remove`

Open MathijsVerbeeck opened this issue 11 months ago • 6 comments

Usage

m365 spo site admin remove [options]

Description

Removes a user or group as site collection administrator

Options

Option Description
-u, --siteUrl <siteUrl> The URL of the site
--userId [userId] The ID of the user to remove as a site collection admin
--userName [userName] The user principal name of the user to remove as a site collection admin
--groupId [groupId] The ID of the Microsoft Entra ID group to remove as a site collection admin
--groupName [groupName] The name of the Microsoft Entra ID group to remove as a site collection admin
--asAdmin If specified, we will use the SharePoint admin center to execute the command
-f, --force Don't prompt for confirmation

Examples

Removes user as site collection admin

m365 spo site admin remove --siteUrl https://contoso.sharepoint.com --userId 600713c5-53c6-4f24-b454-3c35e22b2639

Removes group as site collection admin without prompting for confirmation

m365 spo site admin remove --siteUrl https://contoso.sharepoint.com --groupName SP_Administrators --force

Response

No response

Additional info

We should add correct error handling as when we try to remove the primary site collection admin or when we try to remove the final site collection admin, as there always has to be atleast one if I'm not mistaken

MathijsVerbeeck avatar Mar 05 '24 15:03 MathijsVerbeeck

Also check out my comment here: https://github.com/pnp/cli-microsoft365/issues/5882#issuecomment-1981160284

martinlingstuyl avatar Mar 06 '24 15:03 martinlingstuyl

@martinlingstuyl I have updated the specs to include the --asAdmin flag.

MathijsVerbeeck avatar Mar 06 '24 15:03 MathijsVerbeeck

Should we use a -a short?

martinlingstuyl avatar Mar 06 '24 15:03 martinlingstuyl

Should we use a -a short?

We could, but it would be quite inconsistent as we do not use this short with the Power Platform commands that we offer.

MathijsVerbeeck avatar Mar 06 '24 15:03 MathijsVerbeeck

LGTM 👍

Adam-it avatar Mar 06 '24 15:03 Adam-it

Hi, could you assign me to this task as it is similar to other m365 spo site admin ... commands :)

mkm17 avatar May 08 '24 14:05 mkm17