Open Lyx09 opened 2 weeks ago
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
@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.
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
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).
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
.
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:
The team exists, and I have do have permissions to delete the Team:
Trying to reach the endpoint directly, using Invoke-MgGraphRequest instead gives the same result (as expected):
The enpoint is defined when using "Find-MgGraphCommand":
The endpoint does not seem to allow the "DELETE" method, but the "GET" method works:
Moreover, the documentation and Get-Help shows incorrect examples:
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
Connect-MgGraph
Remove-MgTeam -TeamId "{teamid}"
SDK Version
Latest version known to work for scenario above?
No response
Known Workarounds
Use MicrosoftTeams module instead with the "Remove-Team" and "-GroupId" parameter
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
Other information
No response