protected override void ExecuteCmdlet() { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { var channelId = Channel.GetId(HttpClient, AccessToken, groupId); if (channelId != null) { try { string entityId = null; string contentUrl = null; string removeUrl = null; string webSiteUrl = null; string teamsAppId = null; switch (Type) { case TeamTabType.Word: case TeamTabType.Excel: case TeamTabType.PowerPoint: case TeamTabType.PDF: { entityId = officeFileParameters.EntityId; contentUrl = officeFileParameters.ContentUrl; break; } case TeamTabType.DocumentLibrary: case TeamTabType.WebSite: { contentUrl = documentLibraryParameters.ContentUrl; break; } case TeamTabType.Custom: { entityId = customParameters.EntityId; contentUrl = customParameters.ContentUrl; removeUrl = customParameters.RemoveUrl; webSiteUrl = customParameters.WebSiteUrl; teamsAppId = customParameters.TeamsAppId; break; } } TeamsUtility.AddTabAsync(HttpClient, AccessToken, groupId, channelId, DisplayName, Type, teamsAppId, entityId, contentUrl, removeUrl, webSiteUrl).GetAwaiter().GetResult(); } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw ex; } } } else { throw new PSArgumentException("Channel not found"); } } else { throw new PSArgumentException("Group not found"); } }