$location = Get-ItemProperty "HKLM:SOFTWARE\Microsoft\SMS\Setup" | Select-Object -ExpandProperty "UI Installation Directory"
Resolves to C:\Program Files\Microsoft Configuration Manager\AdminConsole.
That is the correct registry key. However AdminConsole folder is not in the C:\Program Files\Microsoft Configuration Manager
The Module is only in x86 folder. I changed the registry 'UI Installation Directory' to point to: C:\Program Files (x86)\Microsoft Configuration Manager\AdminConsole and script is working after that change.