如何在 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
在以上示例中:
Get-ItemProperty
- 這將讓您獲取登錄的全部詳細資訊。Get-ItemPropertyValue
- 這將讓您獲取登錄的當前值。-Path
- 這將指定命令的路徑。-Name
- 這將指定命令的項目名稱。
請記住,您需要在命令中提供特定登錄的路徑和名稱。
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