protected override void ExecuteCmdlet() { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { var channelId = Channel.GetId(HttpClient, AccessToken, groupId); if (channelId != null) { var tabId = string.Empty; if (string.IsNullOrEmpty(Identity.Id)) { tabId = Identity.Id.ToString(); } else { var tab = Identity.GetTab(HttpClient, AccessToken, groupId, channelId); if (tab != null) { tabId = tab.Id; } else { throw new PSArgumentException("Cannot find tab"); } } if (Force || ShouldContinue("Removing the tab will remove the settings of this tab too.", Properties.Resources.Confirm)) { var response = TeamsUtility.DeleteTab(AccessToken, HttpClient, groupId, channelId, tabId); if (!response.IsSuccessStatusCode) { if (GraphHelper.TryGetGraphException(response, out GraphException ex)) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } } else { throw new PSInvalidOperationException("Tab remove failed"); } } } } else { throw new PSArgumentException("Channel not found"); } } else { throw new PSArgumentException("Team not found", nameof(Team)); } }