You can change 'limited' to 'sampled' or 'detailed' for more in depth scanning of the indexes
Remove this where clause if you would like to see system DBs (Where DatabaseID > 4)
Increase or decrease this where clause to adjust the number of fragments per db returned (Where i.rnk <= 25)
Due to the use of DB_ID, the compatibility level all databases must be 90.
INDEX_ID > 0 omits heap data
Page_Count > 500 omits indexes with less than 500 pages where defragmentation would not necessarily be helpful