Query to obtain indexes information - why does it produce duplicated values?
If you check where the different column values come from (PAGE_COUNT and AVG_FRAGMENTATION_IN_PERCENT), you will see they are from the system function SYS.DM_DB_INDEX_PHYSICAL_STATS. 

Just before joining with SYS.DM_DB_INDEX_PHYSICAL_STATS you have joined SYS.INDEXES with SYS.DM_DB_PARTITION_STATS, so your row is detailed by object_id, index_id, partition_number. Try joining by these 3 against SYS.DM_DB_INDEX_PHYSICAL_STATS (since the function result is actually detailed by these 3):

INNER JOIN SYS.DM_DB_INDEX_PHYSICAL_STATS (DB_ID(), NULL, NULL, NULL, NULL) AS IXS ON 
    IXS.OBJECT_ID = T.OBJECT_ID AND
    IXS.index_id = I.index_id AND
    IXS.partition_number = PS.partition_number