Get-ItemPropertyValue
取得指定項目的一或多個屬性的值。
語法
Path (預設值)
Get-ItemPropertyValue
[[-Path] <String[]>]
[-Name] <String[]>
[-Filter <String>]
[-Include <String[]>]
[-Exclude <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
LiteralPath
Get-ItemPropertyValue
[-Name] <String[]>
-LiteralPath <String[]>
[-Filter <String>]
[-Include <String[]>]
[-Exclude <String[]>]
[-Credential <PSCredential>]
[<CommonParameters>]
Description
Get-ItemPropertyValue 會取得您指定的屬性在您使用 Name 參數時的目前值。該屬性位於您以 Path 或 LiteralPath 參數指定的路徑中。
範例
範例 1:取得 ProductID 屬性的值
此命令會取得 Windows 登錄提供者中 “\SOFTWARE\Microsoft\Windows NT\CurrentVersion” 物件的 ProductID 属性值。
Get-ItemPropertyValue 'HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion' -Name ProductID
94253-50000-11141-AA785
範例 2:取得檔案或資料夾的最後一次寫入時間
此命令會從 FileSystem 提供者的 資料夾中,取得 C:\Program Files\PowerShell 屬性,即檔案或資料夾上次變更的時間值。
Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime
Wednesday, September 3, 2014 2:53:22 PM
範例 3:取得檔案或資料夾的多個屬性值
此命令會取得資料夾的 LastWriteTime、CreationTime和 Root 属性的值。 屬性值會依照您指定屬性名稱的順序傳回。
Get-ItemPropertyValue -Path 'C:\Program Files\PowerShell' -Name LastWriteTime,CreationTime,Root
Tuesday, March 23, 2021 6:53:13 AM
Monday, August 14, 2017 1:42:40 PM
Parent :
Root : C:\
FullName : C:\
Extension :
Name : C:\
Exists : True
CreationTime : 10/30/2015 1:28:30 AM
CreationTimeUtc : 10/30/2015 6:28:30 AM
LastAccessTime : 5/26/2021 9:22:24 AM
LastAccessTimeUtc : 5/26/2021 2:22:24 PM
LastWriteTime : 5/25/2021 7:25:08 AM
LastWriteTimeUtc : 5/25/2021 12:25:08 PM
Attributes : Hidden, System, Directory
Mode : d--hs
ModeWithoutHardLink : d--hs
BaseName : C:\
Target :
LinkType :
參數
-Credential
備註
任何與 PowerShell 一起安裝的提供者都不支援此參數。 若要模擬其他使用者,或在執行此 Cmdlet 時提升您的認證,請使用 Invoke-Command。
參數屬性
| 類型: | PSCredential |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Exclude
指定要在此 Cmdlet 作業中排除的項目或多項,並以字串陣列形式表示。 此參數的值對 路徑 參數進行限定。 輸入路徑元素或模式,例如 *.txt。 允許使用通配符字元。 只有在命令包含項目的內容,例如 時,C:\Windows\* 參數才有效,其中通配符會指定 C:\Windows 目錄的內容。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Filter
指定篩選條件,以限定 Path 參數。 FileSystem 提供者是唯一已安裝且支援使用篩選的 PowerShell 提供者。 您可以在 about_Wildcards中找到 FileSystem 篩選語言的語法。 篩選比其他參數更有效率,因為提供者會在 Cmdlet 取得物件時套用它們,而不是在擷取對象之後讓 PowerShell 篩選物件。
參數屬性
| 類型: | String |
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Include
指定此 Cmdlet 在操作中包含的一個或多個專案,這些專案是以字串陣列的形式表示。 此參數的值對 路徑 參數進行限定。 輸入路徑元素或模式,例如 "*.txt"。 允許使用通配符字元。 只有當命令包含項目的內容,例如 時,C:\Windows\* 參數才有效,其中通配符會指定 C:\Windows 目錄的內容。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-LiteralPath
指定通往一個或多個位置的路徑。 LiteralPath 的值會按原本輸入的方式使用。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知PowerShell不要將任何字元解譯為逸出序列。
如需詳細資訊,請參閱 about_Quoting_Rules。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | PSPath, LP |
參數集
LiteralPath
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Name
指定要擷取的屬性或屬性名稱。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | PSProperty |
參數集
(All)
| Position: | 1 |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
-Path
指定專案或項目的路徑。 允許使用通配符字元。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | True |
| 不要顯示: | False |
參數集
Path
| Position: | 0 |
| 必要: | False |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
String
您可以傳送包含路徑的字串到此 Cmdlet。
輸出
PSObject
此 Cmdlet 會針對它取得的每個項目屬性值傳回 物件。 物件類型取決於擷取的屬性值。
備註
PowerShell 包含下列 Get-ItemPropertyValue的別名:
- 所有平臺:
gpv
此 Cmdlet 的設計目的是要處理任何提供者所公開的數據。 若要列出會話中可用的提供者,請執行 Get-PSProvider Cmdlet。 如需詳細資訊,請參閱 about_Providers。