1

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?

neontapir
  • 4,698
  • 3
  • 37
  • 52
Alan
  • 53
  • 8

2 Answers2

1

You first check, then if true, do get-item against the path, and query (default) property.

if (-not (Test-Path 'HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX\Version')) { return false; }
$version=(Get-Itemproperty 'HKLM:\SOFTWARE\Macromedia\FlashPlayerActiveX')."Version"
# or whatever is the entry name, I don't have this ActiveX installed
return ($version -eq '18.0.0.203')

It's possible that there would be more updates, so you would have to devise or search for an intelligent version check routine, so that "18.0.0.2020" won't be less than "18.0.0.203". Unlikely, but possible.

Vesper
  • 18,599
  • 6
  • 39
  • 61
  • Thank you for the reply! When I try to write-host it to make sure it is gettingt he right version, it doesnt print anything, am I using it correctly? http://i.imgur.com/2EWIa1E.png – Alan Jul 09 '15 at 14:07
  • 1
    The primary issue with this code is that Version is a property name not a key name with a default value. – EBGreen Jul 09 '15 at 14:14
  • Hmm, it seems to be the right way to use. Fixed the routine. – Vesper Jul 09 '15 at 14:18
  • Also, do you guys know if it is possible to do that over ActiveDirectory? I want to check the registry key value on every computer that I have in ActiveDirectory. Any ideas on that? THANK YOU! – Alan Jul 09 '15 at 14:39
  • Iterate. Use AD to get all workstations, try opening registry [like here](http://stackoverflow.com/questions/15069130/get-remote-registry-value) and get them values. – Vesper Jul 09 '15 at 14:46
1

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'
EBGreen
  • 36,735
  • 12
  • 65
  • 85
  • IIRC ActiveX control has equal values in both 32 and 64-bit branches. While yes, 32/64 bit registry paths are indeed different. – Vesper Jul 09 '15 at 14:20