Writing Mailboxstatistics into SQL Server

Hello All!

I have been looking for a way to name and shame hoarders of emails and those scared of deleting emails! (seems to be a legacy problem here) I would like to export the mailbox stats so can get them onto our company intranet... my web team have said as long as i can get into a database of some description they can work with that.

After some Googling i found what i thought was going to be my gem but its not working and after trying many tweaks I now come to you guys to see if this something that you can spot which might help...

https://blogs.technet.microsoft.com/akapteina/2012/12/04/writing-mailboxstatistics-into-sql-server/

Anyone seen it before or got it working?