Reputation: 685
I have the below code snippet:
$Reg2 = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Machine)
$RegKey2= $Reg.OpenSubKey("SOFTWARE\\TrendMicro\\PC-cillinNTCorp\\CurrentVersion\\Misc.")
$CheckAVVer = $RegKey2.GetValue("ProgramVer")
Whats happening is $CheckAVVer doesn't seem to grab the value. If remove the $CheckAVVer, it works and displays the value.
Please help.
Upvotes: 1
Views: 97
Reputation: 4700
In the second line, change:
$Reg.OpenSubKey("SOFT...
To:
$Reg2.OpenSubKey("SOFT...
And see if that fixes it for you.
$Reg2 = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey('LocalMachine', $Machine)
$RegKey2= $Reg2.OpenSubKey("SOFTWARE\\TrendMicro\\PC-cillinNTCorp\\CurrentVersion\\Misc.")
$CheckAVVer = $RegKey2.GetValue("ProgramVer")
Write-host $CheckAVVer
Upvotes: 1