代码之家  ›  专栏  ›  技术社区  ›  Blue Clouds

Powershell注册表访问多个选项

  •  0
  • Blue Clouds  · 技术社区  · 5 年前

    1. cd HKLM:\ (或设置位置-路径) HKLM:\软件\Microsoft\Windows\CurrentVersion)

      Get-childitem

      Get-Item -path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run

    2. Get-ItemProperty , New-ItemProperty , Set-ItemProperty

    什么时候用一个代替另一个?

    1 回复  |  直到 5 年前
        1
  •  1
  •   Jaykul    5 年前

    它们都是必需的,因为属性值在 Item 对象(并且您看不到具有 ItemProperty 命令)。

    我的2c:注册表提供程序是由某人作为演示编写的,然后发布,现在他们害怕更改它。。。这是解释“物品属性”的唯一方法。

    基本上,当他们将注册表映射到PowerShell提供程序语义时,不再有“Container”和“Leaf”项,而是只有容器,每个容器都有 属性

    所以如果你这么做了 Get-ChildItem HKCU:\SOFTWARE\Microsoft 您将得到一个返回的响应,其中列出了每个子容器的“名称”(Registry Editory(注册表编辑器)将显示为文件夹),并在“属性”标题下列出其中的值-- ,和 Property 返回的对象上的字段实际上只是一个字符串数组,列出属性的名称,以便知道接下来可以做什么:

    • 如果您想以脚本可以访问的方式实际读取这些值,则需要使用 Get-ItemProperty
    • 如果要更改值,则需要使用 Set-ItemProperty
    • New-ItemProperty

    例如,在您的示例中,您可能会看到SecurityHealth:

    The Run key has a SecurityHealth property pointing at SecurityHealthSystray.exe

    Get-ItemProperty -Path HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Run 把一个真正有 SecurityHealth C:\WINDOWS\System32\SecurityHealthSystray.exe

    推荐文章