0
votes

I will like know the versiĆ³n of the agent of AV Mcafee and Endpoint , it's obvious that I do not have connection at ePo console.

I got this script:

$AgentVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine",$Computer).OpenSubKey('HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\McAfee\AgentVersion').GetValue('AgentVersion')
$ProductVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine',$Computer).OpenSubKey('HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\McAfee\SystemCore').GetValue('') 



      " $AgentVer   Agent version: $AgentVer
        $computer   Product version: $ProductVer

But when execute I obtain:

You cannot call a method on a null-valued expression.
At line:2 char:1
+ $AgentVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMa ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.
At line:3 char:1
+ $ProductVer = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('Local ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : InvokeMethodOnNull

    Agent version: 
            10.1.1.1   Product version: 

I don't know how follow, any can help me ?

A greeting and thanks

1

1 Answers

0
votes

You have already specified the registry hive LocalMachine in the OpenRemoteBaseKey call, so it should not be repeated in the argument of OpenSubKey. Also, you should only give subkey path to OpenSubKey, not the full name of the value. This should work:

$hklm = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey("LocalMachine", $Computer)
$subkey = $hklm.OpenSubKey("SOFTWARE\Wow6432Node\McAfee")
$AgentVer = $subkey.GetValue("AgentVersion")
$ProductVer = $subkey.GetValue("SystemCore")