protected override void ExecuteCmdlet() { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { if (ParameterSpecified(nameof(Channel))) { var teamChannels = TeamsUtility.GetChannelsAsync(AccessToken, HttpClient, groupId).GetAwaiter().GetResult(); var channelId = Channel.GetId(HttpClient, AccessToken, groupId); var requestedChannel = teamChannels.FirstOrDefault(c => c.Id == channelId); if (!string.IsNullOrEmpty(channelId) && requestedChannel != null && requestedChannel.MembershipType.ToLower() == TeamChannelType.Private.ToString().ToLower()) { WriteObject(TeamsUtility.GetUsersAsync(HttpClient, AccessToken, groupId, channelId, Role).GetAwaiter().GetResult(), true); } else { WriteWarning("Specified channel is not a private channel. Please specify a private channel name to fetch its users."); } } else { WriteObject(TeamsUtility.GetUsersAsync(HttpClient, AccessToken, groupId, Role).GetAwaiter().GetResult(), true); } } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw; } } } else { throw new PSArgumentException("Group not found"); } }
protected override void ExecuteCmdlet() { var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { if (ParameterSpecified(nameof(Channel))) { var channelId = Channel.GetId(HttpClient, AccessToken, groupId); if (!string.IsNullOrEmpty(channelId)) { WriteObject(TeamsUtility.GetUsersAsync(HttpClient, AccessToken, groupId, channelId, Role).GetAwaiter().GetResult(), true); } } else { WriteObject(TeamsUtility.GetUsersAsync(HttpClient, AccessToken, groupId, Role).GetAwaiter().GetResult(), true); } } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw; } } } else { throw new PSArgumentException("Group not found"); } }