There is a newer Script, that uses the new JSON based service from Microsoft! You should use the newer one instead of this!
I know that there are a few functions and scripts like this available. Honestly, the roots of this function are a bit older.
Now some of the developers at enabling Technology tweaked and extended my old function, and they also quashed out a few bugs!