Rename-ItemProperty

重新命名項目的屬性。

Syntax

Rename-ItemProperty
      [-Path] <String>
      [-Name] <String>
      [-NewName] <String>
      [-PassThru]
      [-Force]
      [-Filter <String>]
      [-Include <String[]>]
      [-Exclude <String[]>]
      [-Credential <PSCredential>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]
Rename-ItemProperty
      -LiteralPath <String>
      [-Name] <String>
      [-NewName] <String>
      [-PassThru]
      [-Force]
      [-Filter <String>]
      [-Include <String[]>]
      [-Exclude <String[]>]
      [-Credential <PSCredential>]
      [-WhatIf]
      [-Confirm]
      [<CommonParameters>]

Description

Cmdlet 會 Rename-ItemProperty 變更指定項目屬性的名稱。 屬性的值不會變更。 例如,您可以使用 Rename-ItemProperty 來變更登錄項目的名稱。

範例

範例 1:重新命名登錄專案

此命令會將機碼中包含的 HKEY_LOCAL_MACHINE\Software\SmpApplication config 登錄專案重新命名為 「oldconfig」。。

Rename-ItemProperty -Path HKLM:\Software\SmpApplication -Name config -NewName oldconfig

參數

-Confirm

執行 Cmdlet 之前先提示您確認。

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Credential

注意

任何與 PowerShell 一起安裝的提供者都不支援此參數。 若要模擬其他使用者,或在執行此 Cmdlet 時提升您的認證,請使用 Invoke-Command

Type:PSCredential
Position:Named
Default value:Current user
Required:False
Accept pipeline input:True
Accept wildcard characters:False

-Exclude

指定此 Cmdlet 在作業中排除的專案或專案,做為字串陣列。 此參數的值會 限定Path 參數。 輸入路徑專案或模式,例如 *.txt。 允許通配符。 Exclude 參數只有在命令包含項目的內容時有效,例如 C:\Windows\*,通配符會指定目錄的內容C:\Windows

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-Filter

指定篩選條件以限定 Path 參數。 FileSystem 提供者是唯一支援使用篩選器的已安裝 PowerShell 提供者。 您可以在 about_Wildcards 中找到 FileSystem 篩選語言的語法。 篩選比其他參數更有效率,因為提供者會在 Cmdlet 取得物件時套用它們,而不是在擷取對象之後讓 PowerShell 篩選物件。

Type:String
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-Force

強制 Cmdlet 重新命名使用者無法存取的物件屬性。 實作會因提供者而異。 如需詳細資訊,請參閱 about_Providers

Type:SwitchParameter
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Include

指定此 Cmdlet 包含在作業中的專案,做為字串陣列。 此參數的值會 限定Path 參數。 輸入路徑專案或模式,例如 "*.txt"。 允許通配符。 Include 參數只有在命令包含項目的內容時有效,例如 C:\Windows\*,其中通配符會指定目錄的內容C:\Windows

Type:String[]
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:True

-LiteralPath

指定項目的路徑。 LiteralPath 的值會與類型完全相同使用。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知PowerShell不要將任何字元解譯為逸出序列。

如需詳細資訊,請參閱 about_Quoting_Rules

Type:String
Aliases:PSPath, LP
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-Name

指定要重新命名之屬性的目前名稱。

Type:String
Aliases:PSProperty
Position:1
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-NewName

指定屬性的新名稱。

Type:String
Position:2
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PassThru

傳回物件,表示項目屬性。 根據預設,此 Cmdlet 不會產生任何輸出。

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Path

指定項目的路徑。 允許通配符。

Type:String
Position:0
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:True

-WhatIf

顯示執行 Cmdlet 後會發生的情況。 未執行 Cmdlet。

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:False
Required:False
Accept pipeline input:False
Accept wildcard characters:False

輸入

String

您可以使用管線將包含路徑但不是常值路徑的字串傳送至此 Cmdlet。

輸出

None

根據預設,此 Cmdlet 不會傳回任何輸出。

PSCustomObject

當您使用 PassThru 參數時,這個 Cmdlet 會 傳回代表已重新命名之專案屬性的 PSCustomObject

備註

PowerShell 包含下列的 Rename-ItemProperty別名:

  • 所有平臺:
    • rnp

Rename-ItemProperty 是設計來使用任何提供者所公開的數據。 若要列出工作階段中可用的提供者,請輸入 Get-PSProvider。 如需詳細資訊,請參閱 about_Providers