lara400
lara400

Reputation: 4736

variable inside or outside of quotes?

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

Answers (1)

CB.
CB.

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

Related Questions