Anydice doesn't have a good built in function which can do this, but it's relatively easy to write a program which can:
function: dupes in DICE:s {
D: 0
loop X over {2..#DICE} {
if ((X-1)@DICE = X@DICE) { D: D + 1}
}
result: D
}
Which will work for any size of die and dice pool, subject to Anydice's normal constraints on processing time (in testing the above capped out at 15d6 and 8d10 pools).
This works by taking advantage of Anydice's semantics when casting dice pools to sequences. When a dice pool is converted to sequence by a function, it produces a sequence representing the result of the roll, sorted from highest to lowest result (so 5d6 might give {6,6,4,3,1} but never {6,4,6,1,3}). As we have a sorted sequence we just iterate over it comparing each value to the previous value; if they are equal, there is a duplicate.