Search code examples
powershellregistry

Check for Registry version data with powershell


I am trying to make a PowerShell script that checks if the Registry Key HKEY_LOCAL_MACHINE\SOFTWARE\Macromedia\FlashPlayerActiveX\Version\ has a value of 18.0.0.203, and return a boolean as to whether is exists or not. I am currently trying to do it with Test-Path, but I am having no luck.

Here is what I have tried: Test-Path 'HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX\Version' But that doesn't give me the data field, which is the version number. Is there any way to accomplish what I want to do?


Solution

  • First you need to get the value. Personally I would suggest WMI rather than the registry so you don't have to worry about 64 bit vs. 32 bit registry paths:

    $version = (Get-WMIObject Win32_Product | ?{$_.name -like '*Adobe Flash Player* ActiveX'}).Version
    

    If you really want to use the registry anyway:

    $version = (Get-ItemProperty 'HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX\').version
    

    Then you can simply compare to get a boolean:

    $bool = $version -eq '18.0.0.203'