How do I get the value of a registry key and ONLY the value using powershell

前端 未结 9 570
醉酒成梦
醉酒成梦 2020-12-13 11:52

Can anyone help me pull the value of a registry key and place it into a variable in PowerShell? So far I have used Get-ItemProperty and reg query

9条回答
  •  盖世英雄少女心
    2020-12-13 12:30

    Given a key \SQL with two properties:

    I'd grab the "MSSQLSERVER" one with the following in-cases where I wasn't sure what the property name was going to be to use dot-notation:

    $regkey_property_name = 'MSSQLSERVER'
    $regkey = get-item -Path 'HKLM:\Software\Microsoft\Microsoft SQL Server\Instance Names\SQL'
    $regkey.GetValue($regkey_property_name)
    

提交回复
热议问题