2012-07-13 52 views
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
$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 .. 
} 
相關問題