protected override void ExecuteCmdlet() { if (Force || ShouldContinue("Removing the channel will also remove all the messages in the channel.", Properties.Resources.Confirm)) { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { var channel = Identity.GetChannel(HttpClient, AccessToken, groupId); if (channel != null) { var response = TeamsUtility.DeleteChannel(AccessToken, HttpClient, groupId, channel.Id); if (!response.IsSuccessStatusCode) { if (GraphHelper.TryGetGraphException(response, out GraphException ex)) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } } else { WriteError(new ErrorRecord(new Exception($"Channel remove failed"), "REMOVEFAILED", ErrorCategory.InvalidResult, this)); } } else { throw new PSArgumentException("Channel not found"); } } else { throw new PSArgumentException("Team not found"); } } } }