Unable to read a 64 bit registry key from a 32 bit version of win2008 using powershell

后端 未结 3 920
醉话见心
醉话见心 2020-12-21 15:47

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 no

3条回答
  •  春和景丽
    2020-12-21 16:25

    If you are running PowerShell on .NET 4 (look at the output of $PSVersionTable) then you can use the new RegistryView enumeration (and OpenRemoteBaseKey overload) with the [Microsoft.Win32.RegistryView]::Registry64 to be able to view the 64-bit registry.

    Alternatively you could use PowerShell remoting since by default you will be connected to the 64-bit PowerShell endpoint on the remote machine e.g.:

    $line = "WIN-QENOBBC64B8"
    Invoke-Command -ComputerName $line {Get-Item 'HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL'}
    

    Note that you may have to enable remoting on the remote server (can't remember if PowerShell remoting is enabled by default on servers). You can do this by running the following commands on the remote server in an elevated/admin PowerShell prompt:

    Set-ExecutionPolicy RemoteSigned
    Enable-PSRemoting
    

提交回复
热议问题