MSGraph Remove-MgTeam

Kristof Van Woensel 41 Reputation points
2024-09-23T13:42:21.0833333+00:00

I'm trying to execute the Remove-MgTeam in Powershell, but I'm getting a 405 error. The same happens with the beta-version. What am I missing? I think I added all necessary Teams/Groups/Directory permissions

My script:

Remove-MgBetaTeam -TeamId $team.id

Error:

Remove-MgBetaTeam :

Status: 405 (MethodNotAllowed)

ErrorCode: UnknownError

Date: 2024-09-23T13:37:42

Headers:

Transfer-Encoding : chunked

Vary : Accept-Encoding

Strict-Transport-Security : max-age=31536000

request-id : 55f7cb88-aa1b-4f90-b4f1-3ff31c64a021

client-request-id : ab6d83e9-bc7a-4e83-a480-8ae1061197b4

x-ms-ags-diagnostic : {"ServerInfo":{"DataCenter":"West Europe","Slice":"E","Ring":"5","ScaleUnit":"003","Rol

eInstance":"AM1PEP****"}}

Microsoft Teams
Microsoft Teams
A Microsoft customizable chat-based workspace.
10,039 questions
Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,943 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,489 questions
0 comments No comments
{count} votes

Accepted answer
  1. LiweiTian-MSFT 18,855 Reputation points Microsoft Vendor
    2024-09-26T06:34:10.2066667+00:00

    Hi @Kristof Van Woensel

    Great to know that the issue has already been resolved and thanks for sharing the solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that the question author cannot accept their own answer. They can only accept answers by others, I'll repost your solution in case you'd like to Accept the answer.

     

    Case Title: MSGraph Remove-MgTeam

     

    Issue Symptom: trying to execute the Remove-MgTeam in Powershell, but I'm getting a 405 error.

    Resolution: Please use module MicrosoftTeams as suggested here works

     

    Thanks for your understanding and support.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

3 additional answers

Sort by: Most helpful
  1. Vasil Michev 105.1K Reputation points MVP
    2024-09-23T17:11:57.0366667+00:00

    There is no DELETE method for a Team resource. Instead, you delete the underlying group. In other words, use the Remove-MgGroup cmdlet instead.

    0 comments No comments

  2. LiweiTian-MSFT 18,855 Reputation points Microsoft Vendor
    2024-09-24T02:38:30.1166667+00:00

    Hi @Kristof Van Woensel

    According to the RFC2616 document, 405 error is defined as follows:

    The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.

    We can troubleshoot the problem through the following points:

    1.Check the API documentation: You should first make sure you are using the API URL correctly. For example, parameters that need to be passed and other conditions.

    2.Try to connect using Advance method: Pass in the relevant parameters and ensure that the necessary request parameters are in the header. For example, User-Agent parameters, Content-type parameters, etc.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


    0 comments No comments

  3. Kristof Van Woensel 41 Reputation points
    2024-09-24T11:39:45.9533333+00:00

    It seems I wasn't the first to encounter this problem.

    The workaround using module MicrosoftTeams as suggested here works.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.