ProductType can be read out of the registry.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ProductOptions

You could also break the script in two, using InGroup() with 3.63 and everything else in 4.xx.

You can search TechNet for info about removing SIDHistory but beware that if you are still in the middle of your migration you may still be relying on it.
_________________________
Give a man a fish and he will be back for more. Slap him with a fish and he will go away forever.