Windows, maybe PSADT, is running Deploy-Application.exe as 32-bit on 64-bit OS

I’m using If ($Is64bit) to run a 32-bit app installer and then create regkeys in HKLM:\Software\Wow6432Node\AppVendor\ using New-Item & New-ItemProperty. I’m using If (!$Is64bit) to run the same 32-bit app installer and then create regkeys in HKLM:\Software\AppVendor. This works perfectly once on a fresh 64-bit VM, but if I do an uninstall and run the same PSADT installer again, I see in Task Manager the process as being 32-bit (Deploy-Application.exe *32) and then my regkeys are written to HKLM:\Software\Wow6432Node\Wow6432Node\AppVendor.

How can I compensate for this craziness?

I think I figured out a work-around…

If ($Is64Bit -and !$Is64BitProcess), write to HKLM:\Software\AppVendor\ and the Windows redirection stuff will put it in HKLM:\Software\Wow6432Node\AppVendor\