无法使用 powershell 从 32 位版本的 win2008 读取 64 位注册表项 [英] Unable to read a 64 bit registry key from a 32 bit version of win2008 using powershell
问题描述
我正在尝试使用 powershell 从 32 位 Windows 2008 读取 64 位版本的 Windows Server 2008 r2 上的以下注册表项,但该值显示为空白且不返回任何值.
Im trying to read the below registry key on a 64 bit version of windows server 2008 r2 from a 32 bit windows 2008 using powershell, but the value comes as blank and does not return anyvalues.
可以帮助我了解如何从 32 位服务器读取 64 位 reg 密钥吗?
can some help me on how can i read a 64 bit reg key from a 32 bit server ?
$line = "WIN-QENOBBC64B8"
$regkey = [Microsoft.Win32.RegistryKey]::OpenRemoteBaseKey([Microsoft.Win32.RegistryHive]::LocalMachine, $line)
$ref = $regKey.OpenSubKey("SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL")
$ref
推荐答案
在 32 位 powershell 中,您可以通过从命令行调用 64 位版本的 reg.exe 来访问 64 位注册表.诀窍在于使用 sysnative 路径而不是 system32,这会让您脱离 syswow64 沙箱并进入真正的 64 位注册表.
From 32bit powershell, you access the 64bit registry by calling the 64bit version of reg.exe from the command line. The trick is in using the sysnative path instead of system32, which gets you out of the syswow64 sandbox and into the real 64 bit registry.
C:\Windows\SysNative\reg.exe QUERY "HKLM\SOFTWARE\Microsoft\Microsoft SQL Server\Instance Names\SQL"
这篇关于无法使用 powershell 从 32 位版本的 win2008 读取 64 位注册表项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!