dsccommunity / xPSDesiredStateConfiguration

DSC resources for configuring common operating systems features, files and settings.
https://dsccommunity.org
MIT License
197 stars 132 forks source link

xPackage ignores InstalledCheckReg parameters #727

Open ekzp opened 2 years ago

ekzp commented 2 years ago

Hi,

I am trying to upgrade PowerBI Desktop x64 from 2.88 to 2.96. It is an EXE package with blank/null/no ProductId therefore I wanted to use the InstalledCheckReg* set of parameters along with CreateCheckRegValue = $true to detect whether the desired version of the package has been installed. This is how I would like control the package upgrade process as new versions are released.

The issue is that xPackage finds an entry for PowerBi Desktop x64 at 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{b0f89799-10a8-4ee2-8ab3-c15e56b7fba2}' and does no further checks. It completely ignores the InstalledCheckReg* parameters and regards the package as installed.

My resource definition:

xPackage PowerBI { Ensure = "Present" Name = "Microsoft PowerBI Desktop (x64)" ProductId = "" Path = "\SERVER\Share\PBIDesktopSetup_x64.exe" Arguments = "-quiet -norestart ACCEPT_EULA=1 REG_SHOWLEADGENDIALOG=0 DISABLE_UPDATE_NOTIFICATION=1" InstalledCheckRegKey = "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DesiredStateConfiguration" InstalledCheckRegValueName = "PowerBI" InstalledCheckRegValueData = "2.96.901.0" CreateCheckRegValue = $true }

Log excerpt:

VERBOSE: [MYSERVER]: LCM: [ Start Resource ] [[xPackage]PowerBI] VERBOSE: [MYSERVER]: LCM: [ Start Test ] [[xPackage]PowerBI] VERBOSE: [MYSERVER]: [[xPackage]PowerBI] The path extension was '.exe'. VERBOSE: [MYSERVER]: [[xPackage]PowerBI] Ensure is 'Present'. VERBOSE: [MYSERVER]: [[xPackage]PowerBI] product 'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall{b0f89799-10a8-4ee2-8ab3-c15e56b7fba2}' found. VERBOSE: [MYSERVER]: [[xPackage]PowerBI] product as boolean is 'True'. VERBOSE: [MYSERVER]: [[xPackage]PowerBI] The package 'Microsoft PowerBI Desktop (x64)' is installed. VERBOSE: [MYSERVER]: LCM: [ End Test ] [[xPackage]PowerBI] in 0.0630 seconds. VERBOSE: [MYSERVER]: LCM: [ Skip Set ] [[xPackage]PowerBI] VERBOSE: [MYSERVER]: LCM: [ End Resource ] [[xPackage]PowerBI]

For some reason PowerBI Desktop x64 has an Uninstall entry at "'HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.." as well as at "'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft...", even though it is a 64-bit package.

To me the way xPackage behaves looks like a bug. If explicit check conditions are provided in the configuration such as InstalledCheckReg*, it should ignore all other checks. From what I can see I've done it all according to the (scarce) documentation that's available. I am a sysadmin, not a developer, therefore I do not even try to make sense of the source code. I rely solely on the documentation instead.

I also recommend clarifying in the documentation the behavior for cases like the above where there might already be a set of InstalledCheckRegValue Name and Data in the InstalledCheckRegKey but of a different value. What will xPackage do when the value in the Registry does not match the value in the updated configuration file? Will it update it? Will it fail? Will it just ignore it and move on? I would test it myself but given that it doesn't work I cannot.

Please let me know what I am missing and how to fix it.

Thank you.

ekzp commented 2 years ago

Another thought: The documentation isn't clear on the InstalledCheckRegKey parameter behavior. Will xPackage create multiple levels of Registry keys if not found in the Registry, or does it have to be created by other means before xPackage can use it?

Scenario: I want to check package install status by means of InstalledCheckReg* parameters. I want to store the InstalledCheckRegValueName and its associated InstalledCheckRegValueData at the path identified by InstalledCheckRegKey, say, HKLM\Software\DSC\%Name%\, where %Name% is an arbitrary string that identifies an application, e.g. PowerBIDesktop. There I store the value identified by InstalledCheckRegValueName, e.g. PowerBIVersion.

Question: Suppose I only have "HKLM\Software". The "DSC\%Name% bit" is missing. Will xPackage create the "DSC" and "%Name%" Registry keys as well, or will it fail unless I create them beforehand?

Thank you.