2012-07-06 96 views
0

我想从注册表项中获取产品版本。在我希望控制台向最终用户显示产品版本的地方停滞不前 - 我一直在获取意外的令牌。变量内部或外部的引号?

我试着移动引号和东西,但仍然无济于事。

我想我需要改变,“如果”,以“$ SEPVersion.ProductVersion -eq‘11.0.5002.333’) - 我这样做,但我仍然得到错误

任何帮助,将不胜感激。

$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 } 

回答

1

试试这个:

$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" 
} 
+0

BRILLIANT非常感谢 - 这完美地工作! – lara400 2012-07-06 14:03:39