Reputation: 4736
I am trying to get a product version from a registry key. Getting a bit stuck where I want the console to display the product version to the end user - I keep on getting unexpected token.
I tried moving the quotes around and stuff but still no avail.
I am thinking I need to change the "if" to "$SEPVersion.ProductVersion -eq "11.0.5002.333") - I did that but I still get errors.
Any help would be appreciated:
$SEPVersion = Get-ItemProperty 'HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC' -Name 'ProductVersion' | fl ProductVersion -ErrorAction SilentlyContinue
if ($SEPVersion-eq "11.0.5002.333") {
"SEP Version is correct the version is set to" $SEPVersion
}
else {
"SEP Version is INCORRECT - Please resolve this - the version of SEP is " $SEPVersion }
Upvotes: 0
Views: 303
Reputation: 60910
Give this a try:
$SEPVersion = (Get-ItemProperty 'HKLM:\SOFTWARE\Symantec\Symantec Endpoint Protection\SMC' -Name 'ProductVersion' -ea SilentlyContinue ).Productversion
if ($SEPVersion -eq "11.0.5002.333")
{
"SEP Version is correct the version is set to $SEPVersion"
}
else
{
"SEP Version is INCORRECT - Please resolve this - the version of SEP is $SEPVersion"
}
Upvotes: 1