Unable to Create Regkey after Compile to EXE

Hello,

I’m having a problem after compiling my ps1 to Exe.

Here is a Simple Code:

New-Item -Path "HKLM:\SOFTWARE\" -Name "DiscoveryMethodSCCM" -Force
New-Item -Path "HKLM:\SOFTWARE\DiscoveryMethodSCCM\" -Name "Script"-Force
New-Item -Path "HKLM:\SOFTWARE\DiscoveryMethodSCCM\Script\" -Name "Update" -Force
New-Item -Path "HKLM:\SOFTWARE\DiscoveryMethodSCCM\Script\Update\" -Name "7.0.0.92" -Force
New-ItemProperty -Path "HKLM:\SOFTWARE\DiscoveryMethodSCCM\Script\Update\7.0.0.92" -Name "CleanedTeamcenterInstall" -PropertyType "String" -Value "Completed" -force

I try to run this code in powershell directly and it works fine.
But I cant see this regkey in regedit.

I set in package.psd1 this line:

 PowerShellArguments = '-ExecutionPolicy bypass'

Did anyone have this kind of problem?

Thanks in advance

It may be because the exe was compiled as x86 and the registry redirection is kicking it. Try setting the platform to x64.

Hi Adam,

Thanks for your solution , it works.

Thanks again