protected override void ExecuteCmdlet() { if (ParameterSpecified(nameof(Identity))) { var groupId = Identity.GetGroupId(HttpClient, AccessToken); if (groupId != null) { WriteObject(TeamsUtility.GetTeam(AccessToken, HttpClient, groupId)); } else { throw new PSArgumentException("Team not found"); } } else { WriteObject(TeamsUtility.GetTeams(AccessToken, HttpClient), true); } }
protected override void ExecuteCmdlet() { var groupId = Identity.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { var team = TeamsUtility.GetTeam(AccessToken, HttpClient, groupId); 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 ((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.UpdateGroup(HttpClient, AccessToken, groupId, group); } 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.UpdateTeam(HttpClient, AccessToken, groupId, teamCI.ToTeam()); WriteObject(updated); } } catch (GraphException ex) { if (ex.Error != null) { throw new PSInvalidOperationException(ex.Error.Message); } else { throw ex; } } } else { throw new PSArgumentException("Team not found"); } }