This script uses GlideAggregate to search a field on a table for duplicate values. It then returns the value with duplicates in an array.
var xx = new GlideAggregate('table');
xx.addAggregate('COUNT', 'field');
xx.addHaving('COUNT', 'field', '>', '1');
xx.query();
var answer = [];