That gave me the clue I needed to figure this one out. Here's the problem. XML element names are case sensitive, and your script has the casing wrong on one of them: IPAddress should be IpAddress. When I changed this line:
$build = $build + "<IPAddress><Address>$block</Address></IPAddress>"
To this:
$build = $build + "<IpAddress><Address>$block</Address></IpAddress>"
It started working. And if you look at Madhavan's post that you linked to, you will see that's how the IpAddress element is spelled there too.
I can't say how your script could have worked in 10.6. I don't have a 10.6 installation handy to test against, but I checked the source code history for that class to see if some developer had foolishly changed the casing of that element, but it has not changed there.