Brad, I would like to suggest a small correction to your script. Since the GAM and SGAM pages are repeated every 64000 extents (~4Gb), this means that you will have to introduce some logic in your script to check for this, especially in a high volume production systems, where the tempdb files are way beyond 4Gb.
For example, you can use a formula similar to:
for GAM pages: (the page ID is 2) % 511232
for SGAM pages: (the page ID is 3) % 511232
Otherwise your script will be inaccurate.
Regards,
Feodor Georgiev
Make everything as simple as possible, but not simpler. –Albert Einstein