Skip to content

New command: m365 spe containertype remove #5992

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Adam-it opened this issue Apr 24, 2024 · 8 comments
Closed

New command: m365 spe containertype remove #5992

Adam-it opened this issue Apr 24, 2024 · 8 comments
Assignees
Milestone

Comments

@Adam-it
Copy link
Member

Adam-it commented Apr 24, 2024

Usage

m365 spe containertype remove [options]

Description

Remove a specific Container Type

Options

Option Description
-i, --id [id] The Id of the Container Type. Specify either id or name but not both.
-n, --name [name] The Container Type name. Specify either id or name but not both.
-f, --force Don't prompt for confirming removal

Examples

Removes Container Type by id

m365 spe containertype remove --id '4ec4aefd-4fa3-0e4a-20c3-6e68389e7138'

Removes Container Type by name

m365 spe containertype remove --name 'test container'

Removes Container Type by id and doesn't prompt for confirmation

m365 spe containertype remove --id '4ec4aefd-4fa3-0e4a-20c3-6e68389e7138' --force

Default properties

No response

Additional Info

We may use CSOM for this command passing the following

<Request AddExpandoFieldTypeSuffix="true" SchemaVersion="15.0.0.0" LibraryVersion="16.0.0.0" ApplicationName="SharePoint Online PowerShell (16.0.24322.0)"
    xmlns="http://schemas.microsoft.com/sharepoint/clientquery/2009">
    <Actions>
        <ObjectPath Id="58" ObjectPathId="57" />
        <Method Name="RemoveSPOContainerType" Id="59" ObjectPathId="57">
            <Parameters>
                <Parameter TypeId="{b66ab1ca-fd51-44f9-8cfc-01f5c2a21f99}">
                    <Property Name="ContainerTypeId" Type="Guid">{4ec4aefd-4fa3-0e4a-20c3-6e68389e7138}</Property>
                </Parameter>
            </Parameters>
        </Method>
    </Actions>
    <ObjectPaths>
        <Constructor Id="57" TypeId="{268004ae-ef6b-4e9b-8425-127220d84719}" />
    </ObjectPaths>
</Request>

⚠️ Tricky part

The CSOM call does not support filtering by name only by Guid so if we want to add handling also remove the Container Type by name what we will need to do under the hood is query all Container Types and filter them by name.
Also if more than one Container Type will be found (as the name does not have to be unique) CLI (when interactive mode on) should prompt to pick the correct one based on id

@Adam-it Adam-it added new feature needs peer review Needs second pair of eyes to review the spec or PR labels Apr 24, 2024
@Adam-it
Copy link
Member Author

Adam-it commented Apr 24, 2024

@andrewconnell any opinion on that 👆

@milanholemans
Copy link
Contributor

2 remarks:

  1. Only trial Container Types can be removed, does this mean that we don't have to check for the type ourselves and the API will just throw a decent error when you try to remove a standard container type?

Documentation quote:

To delete a trial Container Type, you must remove all Containers of the Trial Container Type first, including from the recycle bin. To remove Containers from the Trial Container Type, refer to Consuming Tenant Admin. Once all the Containers are deleted, Developer Admins can delete the Container Types using the below PowerShell cmdlet.

What will happen if we run this command when there are still containers attached? Will we remove them, or just throw an error?

@Adam-it
Copy link
Member Author

Adam-it commented Apr 25, 2024

2 remarks:

  1. Only trial Container Types can be removed, does this mean that we don't have to check for the type ourselves and the API will just throw a decent error when you try to remove a standard container type?

yes it will return something like Tenant 2942bb31-1d49-4da6-8d3d-d0f9e1141486 cannot delete Container Type 32793d51-870d-07da-113f-b586dee1c12a as it is Standard ContainerType.

Documentation quote:

To delete a trial Container Type, you must remove all Containers of the Trial Container Type first, including from the recycle bin. To remove Containers from the Trial Container Type, refer to Consuming Tenant Admin. Once all the Containers are deleted, Developer Admins can delete the Container Types using the below PowerShell cmdlet.

What will happen if we run this command when there are still containers attached? Will we remove them, or just throw an error?

I think we should throw an error.

@milanholemans
Copy link
Contributor

Ok, thanks for clarifying. Let's open it up then.

@milanholemans milanholemans added help wanted and removed needs peer review Needs second pair of eyes to review the spec or PR labels Apr 26, 2024
@Adam-it Adam-it added the hacktoberfest Issue perfect for hacktoberfest label Sep 24, 2024
@Adam-it Adam-it removed the hacktoberfest Issue perfect for hacktoberfest label Nov 3, 2024
@milanholemans
Copy link
Contributor

We need to handle that only Trail Container Type may be removed. This should be added to the command spec

@Adam-it, why is this? You can remove a regular container type as well, right?

@Adam-it
Copy link
Member Author

Adam-it commented Apr 4, 2025

We need to handle that only Trail Container Type may be removed. This should be added to the command spec

@Adam-it, why is this? You can remove a regular container type as well, right?

nope that's actually by design. You may remove only trial container types and the current spec is based on CSOM based on this command
https://learn.microsoft.com/en-us/powershell/module/sharepoint-online/remove-spocontainertype?view=sharepoint-ps

PnP PS has also the same equivalent https://pnp.github.io/powershell/cmdlets/Remove-PnPContainer.html

milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 4, 2025
milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 4, 2025
milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 4, 2025
milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 4, 2025
@milanholemans
Copy link
Contributor

Seems like developer admins can delete regular container types: https://learn.microsoft.com/en-us/sharepoint/dev/embedded/getting-started/containertypes#deleting-container-types

milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 15, 2025
milanholemans added a commit to milanholemans/cli-microsoft365 that referenced this issue Apr 18, 2025
@Adam-it
Copy link
Member Author

Adam-it commented May 8, 2025

Seems like developer admins can delete regular container types: https://learn.microsoft.com/en-us/sharepoint/dev/embedded/getting-started/containertypes#deleting-container-types

good find. I updated the docs. Seems like that page was added one month after I created this issue 🫤. I am almost sure that at the very beginning it was only possible for trail types 🤔
SharePoint/sp-dev-docs@f60c4d2#diff-a78db218c50c78f30e869d986c20e84bb7283a021aa1b51ae5018f696463bacc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants