If you are running the script on 64bit OS from 32bit context, like a SCCM program, the script will not see the 64bit registries. Fix to open PowerShell in 64bit context, when running from 32bit context like SCCM programs.