Skip to content
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

Remove-MgTeam: Method Not Allowed and incorrect example #2841

Closed
Lyx09 opened this issue Jul 9, 2024 · 6 comments
Closed

Remove-MgTeam: Method Not Allowed and incorrect example #2841

Lyx09 opened this issue Jul 9, 2024 · 6 comments

Comments

@Lyx09
Copy link

Lyx09 commented Jul 9, 2024

Describe the bug

I'm working on a project where I need to delete unused Teams. I'm trying to use the "Remove-MgTeam" command with the "-TeamId" parameter, but I get the following error:
1

The team exists, and I have do have permissions to delete the Team:
6

Trying to reach the endpoint directly, using Invoke-MgGraphRequest instead gives the same result (as expected):
2

The enpoint is defined when using "Find-MgGraphCommand":
7

The endpoint does not seem to allow the "DELETE" method, but the "GET" method works:
3

Moreover, the documentation and Get-Help shows incorrect examples:
4

image

Expected behavior

The team should be deleted, no errors should be thrown.
Documentation should include example of Remove-MgTeam instead of Update-MgTeam

How to reproduce

  1. Connect to MgGraph
    Connect-MgGraph
  2. Execute Remove-MgTeam with the "-TeamId" parameter:
    Remove-MgTeam -TeamId "{teamid}"

SDK Version

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.19.0                Microsoft.Graph.Authentication      {Add-MgEnvironment, Connect-MgGraph, Disconnect-MgGraph, Get-MgContext…}
Script     2.19.0                Microsoft.Graph.Teams               {Add-MgChatMember, Add-MgTeamChannelMember, Add-MgTeamMember, Add-MgTeamPrimaryChannelMember…}

Latest version known to work for scenario above?

No response

Known Workarounds

Use MicrosoftTeams module instead with the "Remove-Team" and "-GroupId" parameter
5

Debug output

Click to expand log Note: identifying information has been removed
DEBUG: [CmdletBeginProcessing]: - Remove-MgTeam begin processing with parameterSet 'Delete'.
DEBUG: [Authentication]: - AuthType: 'Delegated', TokenCredentialType: 'InteractiveBrowser', ContextScope: 'CurrentUser', AppName: 'Microsoft Graph Command Line Tools'.
DEBUG: [Authentication]: - Scopes: [DeviceManagementApps.ReadWrite.All, DeviceManagementConfiguration.ReadWrite.All, DeviceManagementManagedDevices.PrivilegedOperations.All, DeviceManagementManagedDevices.ReadWrite.All, Directory.AccessAsUser.All, Group.ReadWrite.All, openid, Organization.Read.All, profile, User.Read, User.Read.All, User.ReadWrite.All, email].

Confirm
Are you sure you want to perform this action?
Performing the operation "Remove-MgTeam_Delete" on target "Call remote 'DELETE /teams/{team-id}' operation".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
DELETE

Absolute Uri:
https://graph.microsoft.com/v1.0/teams/{teamid}

Headers:
FeatureFlag                   : 00000043
Cache-Control                 : no-store, no-cache
User-Agent                    : Mozilla/5.0,(Windows NT 10.0; Microsoft Windows 10.0.22631; fr-FR),PowerShell/2024.2.2
Accept-Encoding               : gzip
SdkVersion                    : graph-powershell/2.19.0
client-request-id             : {client-request-id}

Body:



DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
MethodNotAllowed

Headers:
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : {request-id}
client-request-id             : {client-request-id}
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"{DataCenter}","Slice":"E","Ring":"5","ScaleUnit":"003","RoleInstance":"{RoleInstance}"}}
Date                          : Tue, 09 Jul 2024 14:00:19 GMT

Body:
{
  "error": {
    "code": "UnknownError",
    "message": "",
    "innerError": {
      "date": "2024-07-09T14:00:19",
      "request-id": "{request-id}",
      "client-request-id": "{client-request-id}"
    }
  }
}


Remove-MgTeam_Delete: 

Status: 405 (MethodNotAllowed)
ErrorCode: UnknownError
Date: 2024-07-09T14:00:19

Headers:
Vary                          : Accept-Encoding
Strict-Transport-Security     : max-age=31536000
request-id                    : {request-id}
client-request-id             : {client-request-id}
x-ms-ags-diagnostic           : {"ServerInfo":{"DataCenter":"{DataCenter}","Slice":"E","Ring":"5","ScaleUnit":"003","RoleInstance":"{RoleInstance}"}}
Date                          : Tue, 09 Jul 2024 14:00:19 GMT

DEBUG: [CmdletEndProcessing]: - Remove-MgTeam end processing.

Configuration

$PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.22631
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
  • OS: Windows 11
  • Architecture: x64

Other information

No response

@Lyx09 Lyx09 added status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 9, 2024
@Eavzz
Copy link

Eavzz commented Jul 9, 2024

Yes, I stumbled upon the same problem, it really bothers me as well...
@Lyx09 If you find a solution please contact me. I will use the workaround for now, however that means I need to import 2 modules instead of 1

@timayabi2020
Copy link
Contributor

timayabi2020 commented Jul 9, 2024

@Lyx09 thank you for logging this issue and apologies for the experience you are having with that cmdlet. Having used both Remove-MgTeam and Invoke-MgGraphCommand cmdlet, clearly points to an API issue where DELETE operation is not supported.
I've also tried the request on graph explorer and got the same result.
image

Further investigations also revealed that the documentation for that particular API is not available here https://learn.microsoft.com/en-us/graph/api/resources/team?view=graph-rest-1.0.

Unfortunately, for API related issues/questions we are not best placed to give an answer. Kindly raise an issue here https://developer.microsoft.com/en-us/graph/support so that the API owner can respond to it.

You can also consider archiving the team as described here

@timayabi2020 timayabi2020 added Service issue Dependency: metadata-issue status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close and removed status:waiting-for-triage An issue that is yet to be reviewed or assigned type:bug A broken experience labels Jul 9, 2024
@Lyx09
Copy link
Author

Lyx09 commented Jul 11, 2024

Thank you for your reply. I'll do as you said. However, even though the endpoint is broken, the examples are still incorrect (Get-Help).

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs: Attention 👋 and removed status:waiting-for-author-feedback Issue that we've responded but needs author feedback to close labels Jul 11, 2024
@Lyx09
Copy link
Author

Lyx09 commented Jul 12, 2024

I contacted the Microsoft support, and they suggested I use an alternative endpoint to delete a team, which I did not think about: Remove-MgGroup -GroupId $groupId
It works in a similar way as Remove-MgTeam.

@timayabi2020
Copy link
Contributor

@Lyx09 thanks for noticing the examples issue. It will be resolved in the next release.

@Lyx09
Copy link
Author

Lyx09 commented Jul 25, 2024

Thank you @timayabi2020.

As a final comment to close this issue, I'd like to add the Microsoft support response I got that confirms that the DELETE /teams/{team-id} endpoint is not valid:
image

Regards,

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

No branches or pull requests

3 participants