如何根据注册表值执行操作?

时间:2012-07-13 15:52:50

标签: powershell registry powershell-v2.0

我有以下注册表项

$rKey="hklm:\SOFTWARE\Wow6432Node\Mycompany\MyProj\Core"

此键将具有以下参数

 DBServer="Installed"
 AppServer="Installed"
 WebServer="Installed"

我想查看

 if DBserver="Installed" Then do some action
 Else Do nothing

 If Appserver="Installe" then do some action
 Else Do nothing

 If Webserver ="Installed" then do some action
 Else Do nothing

如何获取属性值并根据它执行操作?

1 个答案:

答案 0 :(得分:1)

$p = Get-ItemProperty $key

if($p.DBserver -eq "Installed")
{
   .. do some action ..
}

if($p.Appserver-eq "Installed")
{
   .. do some action ..
}

if($p.Webserver -eq "Installed")
{
   .. do some action ..
}