随笔 - 24, 文章 - 0, 评论 - 1, 引用 - 0
数据加载中……

Powershell with Registry

$path = "HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$psv 
= get-itemproperty -path $path 

$psv.RunTimeVersion

$path = "HKLM\SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$WshShell 
= New-Object -ComObject Wscript.Shell 

$WshShell.RegRead(
"$path\RunTimeVersion")

$computer = “."

$hklm 
= 2147483650 

$key 
= "SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$value 
= "RunTimeVersion" 

$wmi 
= [WMIClass] ("\\" + $computer + "\root\default:StdRegProv")

($wmi.GetStringValue($hklm,$key,$value)).svalue

$computer = “."

$hklm 
= 2147483650 

$oreg 
= get-wmiobject -list -namespace root\default -ComputerName $computer | where-object { $_.name -eq "StdRegProv" }

$key 
= "SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$value 
= "RunTimeVersion" 

($oreg.GetStringValue($hklm,$key,$value)).svalue

$hklm = "HKEY_LOCAL_MACHINE" 

$key 
= "SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$value 
= "RunTimeVersion" 

[Microsoft.Win32.Registry]::GetValue(
"$hklm\$key",$value,$null)

$Computer = “.”

$hkey 
= [Microsoft.Win32.RegistryHive]::LocalMachine 

$key 
= "SOFTWARE\Microsoft\PowerShell\1\PowerShellEngine" 

$value 
= "RunTimeVersion" 

$reg 
= [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey($hkey, $Computer) 

$regKey 
= $reg.OpenSubKey($key) 

$regKey.GetValue($value) 

posted on 2009-04-14 22:07 nicktang 阅读(385) 评论(0)  编辑 收藏 引用 所属分类: Powershell

只有注册用户登录后才能发表评论。