如何使用 PowerShell 刪除登錄檔鍵值(屬性)?


若要使用 PowerShell 刪除登錄檔鍵值,我們可以使用 Remove-ItemProperty 命令。假設我們有登錄檔 NodeSoftware,其屬性是 AppSecurity。我們需要使用 Remove-ItemProperty 命令刪除其鍵。

PS C:\> Get-Item HKLM:\SOFTWARE\NodeSoftware
Hive: HKEY_LOCAL_MACHINE\SOFTWARE
Name    Property
----    --------
NodeSoftware    AppSecurity : 1

若要刪除登錄檔鍵,

PS C:\>Remove-ItemProperty HKLM:\SOFTWARE\NodeSoftware\ -Name AppSecurity -Force -Verbose
VERBOSE: Performing the operation "Remove Property" on target "Item: HKEY_LOCAL_MACHINE\SOFTWARE\NodeSoftware\ Property: AppSecurity".

您還可以透過設定位置來刪除屬性。例如,

示例

PS C:\> Set-Location HKLM:\SOFTWARE\NodeSoftware
PS HKLM:\SOFTWARE\NodeSoftware> Remove-ItemProperty -Path . -Name AppSecurity -Force -Verbose

若要使用管道刪除項屬性,

Get-Item HKLM:\SOFTWARE\NodeSoftware | Remove-ItemProperty -Name AppSecurity -Force -Verbose

更新於: 08-Feb-2021

11K+ 瀏覽量

啟動您的 職業生涯

完成課程獲得認證

開始吧
廣告
© . All rights reserved.