protected override void ExecuteCmdlet() { Model.Teams.TeamChannel channel = null; var groupId = Team.GetGroupId(HttpClient, AccessToken); if (groupId != null) { try { TeamsUtility.AddUser(HttpClient, AccessToken, groupId, User, Role); 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"); } }