如何在 PowerShell 中查找注册表项

  1. 在 PowerShell 中获取特定注册表名称
  2. 在 PowerShell 中获取特定注册表值
如何在 PowerShell 中查找注册表项

注册表键是 Windows 中非常重要的部分,包含硬件、软件、用户等的设置和信息。它的工作方式类似于数据库。

在 Windows 中,我们有一个 注册表编辑器 用于编辑、修改或创建注册表键或参数。

但我们也可以通过使用 PowerShell 完成类似的任务。Windows PowerShell 包含执行任何与注册表键相关的任务所需的所有工具。

有时我们需要搜索特定的注册表键及其值。在本文中,我们将看到如何使用 Windows PowerShell 搜索特定的注册表键及其值。

此外,我们将通过使用必要的示例和解释讨论该主题,以使主题更容易理解。

查找任何注册表元素的值或详细信息的一般语法如下:

Get-ItemProperty -Path 'HKLM:YOUR PATH TO REGISTRY' -Name "PROVIDE YOUR REGISTRY NAME"

在 PowerShell 中获取特定注册表名称

在下面的示例中,我们将找到位于 HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Capture\OpacityCoefficientPercentage 注册表的详细信息。

现在我们示例的代码将如下所示。

Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Capture\' -Name "OpacityCoefficientPercentage"

运行上述示例命令后,您将在 PowerShell 窗口中获得如下输出。

获取项属性 -路径命令

在 PowerShell 中获取特定注册表值

在此示例中,我们将找到位于 HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Capture\OpacityCoefficientPercentage 注册表的值。

现在我们示例的代码将如下所示。

Get-ItemPropertyValue -Path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Capture\' -Name "OpacityCoefficientPercentage"

运行上述示例命令后,您将在 PowerShell 窗口中获得如下输出。

100

在上述示例中:

  1. Get-ItemProperty - 这将让您获取注册表的完整详细信息。
  2. Get-ItemPropertyValue - 这将让您获取注册表的当前值。
  3. -Path - 这将指定命令的路径。
  4. -Name - 这将指定命令项的名称。

请记住,您需要在命令中提供特定注册表的路径和名称。

Enjoying our tutorials? Subscribe to DelftStack on YouTube to support us in creating more high-quality video guides. Subscribe
作者: MD Aminul Islam
MD Aminul Islam avatar MD Aminul Islam avatar

Aminul Is an Expert Technical Writer and Full-Stack Developer. He has hands-on working experience on numerous Developer Platforms and SAAS startups. He is highly skilled in numerous Programming languages and Frameworks. He can write professional technical articles like Reviews, Programming, Documentation, SOP, User manual, Whitepaper, etc.

LinkedIn

相关文章 - PowerShell Registry