protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(Identity))) { var groupId = Identity.GetGroupId(HttpClient, AccessToken); if (groupId != null) { WriteObject(TeamsUtility.GetTeamAsync(AccessToken, HttpClient, groupId).GetAwaiter().GetResult()); } } else { WriteObject(TeamsUtility.GetTeamsAsync(AccessToken, HttpClient).GetAwaiter().GetResult(), true); } }
protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(Identity))) { var groupId = Identity.GetGroupId(HttpClient, AccessToken); if (groupId != null) { WriteObject(TeamsUtility.GetTeamAsync(AccessToken, HttpClient, groupId).GetAwaiter().GetResult()); } else { WriteError(new PSArgumentException("Team not found"), ErrorCategory.ObjectNotFound); } } else { WriteObject(TeamsUtility.GetTeamsAsync(AccessToken, HttpClient).GetAwaiter().GetResult(), true); } }
protected override void ExecuteCmdlet() { var groupId = Identity.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { var team = TeamsUtility.GetTeamAsync(AccessToken, HttpClient, groupId).GetAwaiter().GetResult(); var updateGroup = false; var group = new Group(); if (team != null) { if (ParameterSpecified(nameof(DisplayName)) && team.DisplayName != DisplayName) { updateGroup = true; group.DisplayName = DisplayName; } else { team.DisplayName = null; } if (ParameterSpecified(nameof(Description)) && team.Description != Description) { updateGroup = true; group.Description = Description; } else { team.Description = null; } if (ParameterSpecified(nameof(Visibility)) && (GroupVisibility)Enum.Parse(typeof(GroupVisibility), Visibility.ToString()) != team.Visibility) { group.Visibility = (GroupVisibility)Enum.Parse(typeof(GroupVisibility), Visibility.ToString()); updateGroup = true; } team.IsArchived = null; // cannot update this value; if (updateGroup) { TeamsUtility.UpdateGroupAsync(HttpClient, AccessToken, groupId, group).GetAwaiter().GetResult(); } var teamCI = new TeamCreationInformation(); teamCI.AllowAddRemoveApps = ParameterSpecified(nameof(AllowAddRemoveApps)) ? AllowAddRemoveApps : null; teamCI.AllowChannelMentions = ParameterSpecified(nameof(AllowChannelMentions)) ? AllowChannelMentions : null; teamCI.AllowCreateUpdateChannels = ParameterSpecified(nameof(AllowCreateUpdateChannels)) ? AllowCreateUpdateChannels : null; teamCI.AllowCreateUpdateRemoveConnectors = ParameterSpecified(nameof(AllowCreateUpdateRemoveConnectors)) ? AllowCreateUpdateRemoveConnectors : null; teamCI.AllowCreateUpdateRemoveTabs = ParameterSpecified(nameof(AllowCreateUpdateRemoveTabs)) ? AllowCreateUpdateRemoveTabs : null; teamCI.AllowCustomMemes = ParameterSpecified(nameof(AllowCustomMemes)) ? AllowCustomMemes : null; teamCI.AllowDeleteChannels = ParameterSpecified(nameof(AllowDeleteChannels)) ? AllowDeleteChannels : null; teamCI.AllowGiphy = ParameterSpecified(nameof(AllowGiphy)) ? AllowGiphy : null; teamCI.AllowGuestCreateUpdateChannels = ParameterSpecified(nameof(AllowGuestCreateUpdateChannels)) ? AllowGuestCreateUpdateChannels : null; teamCI.AllowGuestDeleteChannels = ParameterSpecified(nameof(AllowGuestDeleteChannels)) ? AllowGuestDeleteChannels : null; teamCI.AllowOwnerDeleteMessages = ParameterSpecified(nameof(AllowOwnerDeleteMessages)) ? AllowOwnerDeleteMessages : null; teamCI.AllowStickersAndMemes = ParameterSpecified(nameof(AllowStickersAndMemes)) ? AllowStickersAndMemes : null; teamCI.AllowTeamMentions = ParameterSpecified(nameof(AllowTeamMentions)) ? AllowTeamMentions : null; teamCI.AllowUserDeleteMessages = ParameterSpecified(nameof(AllowUserDeleteMessages)) ? AllowUserDeleteMessages : null; teamCI.AllowUserEditMessages = ParameterSpecified(nameof(AllowUserEditMessages)) ? AllowUserEditMessages : null; teamCI.Classification = ParameterSpecified(nameof(Classification)) ? Classification : null; var updated = TeamsUtility.UpdateTeamAsync(HttpClient, AccessToken, groupId, teamCI.ToTeam()).GetAwaiter().GetResult(); WriteObject(updated); } } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw; } } } else { throw new PSArgumentException("Team not found"); } }