Clear-ItemProperty
刪除屬性的值,但是它不會刪除該屬性。
語法
Clear-ItemProperty [-LiteralPath] <string[]> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]
Clear-ItemProperty [-Path] <string[]> [-Name] <string> [-Credential <PSCredential>] [-Exclude <string[]>] [-Filter <string>] [-Force] [-Include <string[]>] [-PassThru] [-Confirm] [-WhatIf] [-UseTransaction] [<CommonParameters>]
描述
Clear-ItemProperty Cmdlet 會刪除屬性的值,但是它不會刪除該屬性。您可以用這個 cmdlet 刪除登錄值中的資料。
參數
-Credential <PSCredential>
指定具有執行此動作之權限的使用者帳戶。預設為目前使用者。
請輸入使用者名稱,例如 "User01" 或 "Domain01\User01",或是輸入 PSCredential 物件,例如由 Get-Credential Cmdlet 所產生的物件。如果輸入使用者名稱,將會提示您提供密碼。
所有隨 Windows PowerShell 安裝的提供者都不支援此參數。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
true (ByPropertyName) |
接受萬用字元? |
false |
-Exclude <string[]>
忽略指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt" 或 "s*"。允許使用萬用字元。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-Filter <string>
指定以提供者的格式或語言表示的篩選器。此參數的值用於限定 Path 參數。篩選器的語法 (包括萬用字元的用法) 依提供者而定。篩選器比其他參數更有效率,因為提供者會在擷取物件時套用篩選器,而非等到 Windows PowerShell 擷取物件後才進行篩選。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-Force
允許此 Cmdlet 在使用者無法以其他方式存取的項目中刪除屬性。實作因提供者而異。如需詳細資訊,請參閱 about_Providers。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-Include <string[]>
只清除指定的項目。此參數的值用於限定 Path 參數。輸入路徑元素或模式,例如 "*.txt"。允許使用萬用字元。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-LiteralPath <string[]>
指定要清除的屬性所在路徑。LiteralPath 與 Path 不同,係取用實際輸入的內容做為參數值。任何字元均不被解譯成萬用字元。如果路徑中包含逸出字元,請將其置於單引號內。單引號係告訴 Windows PowerShell 不要將任何字元解譯成逸出序列。
必要? |
true |
位置? |
1 |
預設值 |
|
接受管線輸入? |
true (ByPropertyName) |
接受萬用字元? |
false |
-Name <string>
指定要清除的屬性名稱,例如登錄值的名稱。不允許使用萬用字元。
必要? |
true |
位置? |
2 |
預設值 |
|
接受管線輸入? |
true (ByPropertyName) |
接受萬用字元? |
false |
-PassThru
傳回代表已清除之項目屬性的物件。根據預設,此 Cmdlet 不會產生任何輸出。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-Path <string[]>
指定要清除的屬性所在路徑。允許使用萬用字元。
必要? |
true |
位置? |
1 |
預設值 |
|
接受管線輸入? |
true (ByValue, ByPropertyName) |
接受萬用字元? |
false |
-Confirm
在執行命令前先提示確認。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-WhatIf
說明執行命令時將會發生何種情況,但不會實際執行命令。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
-UseTransaction
將命令加入現用交易中。此參數只有當交易進行中時才有效。如需詳細資訊,請參閱 about_Transactions。
必要? |
false |
位置? |
named |
預設值 |
|
接受管線輸入? |
false |
接受萬用字元? |
false |
<CommonParameters>
這個 Cmdlet 支援一般參數:-Verbose、-Debug、-ErrorAction、-ErrorVariable、-OutBuffer 和 -OutVariable。如需詳細資訊,請參閱 about_Commonparameters.
輸入和輸出
輸入型別是可經由管道輸出至 Cmdlet 的物件型別。傳回型別則是 Cmdlet 所傳回的物件型別。
輸入 |
System.String 您可以經由管道將路徑字串輸出至 Clear-ItemProperty。 |
輸出 |
無或 System.Management.Automation.PSCustomObject 當您使用 PassThru 參數時,Clear-ItemProperty 會產生可代表已清除之項目屬性的 PSCustomObject 物件。否則,這個 Cmdlet 不會產生任何輸出。 |
附註
您可以使用 Clear-ItemProperty 刪除登錄值中的資料,而不刪除此登錄值。如果此值的資料類型是二進位或 DWORD,清除資料便會將此值設為零。否則,此值是空的。
您也可以利用內建的別名 "clp" 來參照 Clear-ItemProperty。如需詳細資訊,請參閱 about_Aliases。
Clear-ItemProperty Cmdlet 設計的用意是要操作任一提供者所公開的資料。若要列出可在工作階段中使用的提供者,請輸入 "Get-PSProvider"。如需詳細資訊,請參閱 about_Providers。
範例 1
C:\PS>clear-itemproperty -path HKLM:\Software\MyCompany\MyApp -name Options
描述
-----------
這個命令會刪除 HKEY_LOCAL_MACHINE\Software\MyCompany 之 MyApp 子機碼中的 Options 登錄值資料。
因為這個命令是從檔案系統磁碟機 (C:) 所發出,所以它會使用指到 HKLM: 磁碟機的完整路徑和 Software\MyCompany\MyApp 子機碼。它會使用 Name 參數指定 Options 值。
請參閱
概念
about_Providers
Copy-ItemProperty
New-ItemProperty
Move-ItemProperty
Rename-ItemProperty
Get-ItemProperty
New-ItemProperty