protected override void ExecuteCmdlet() { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { var channel = TeamsUtility.AddChannelAsync(AccessToken, HttpClient, groupId, DisplayName, Description, Private, OwnerUPN).GetAwaiter().GetResult(); WriteObject(channel); } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw ex; } } } else { throw new PSArgumentException("Group not found"); } }