Convert-Path
將路徑從 Windows PowerShell 路徑轉換為 Windows PowerShell 提供者路徑。
語法
Path (預設值)
Convert-Path
[-Path] <String[]>
[-UseTransaction]
[<CommonParameters>]
LiteralPath
Convert-Path
-LiteralPath <String[]>
[-UseTransaction]
[<CommonParameters>]
Description
Convert-Path Cmdlet 會將路徑從 Windows PowerShell 路徑轉換為 Windows PowerShell 提供者路徑。
範例
範例 1:將工作目錄轉換為標準檔案系統路徑
PS C:\> Convert-Path .
此命令會將以點 (.) 表示的目前工作目錄轉換成標準檔案系統路徑。
範例 2:將提供者路徑轉換為標準登錄路徑
PS C:\> Convert-Path HKLM:\Software\Microsoft
此命令會將 Windows PowerShell 提供者路徑轉換為標準登錄路徑。
範例 3:將路徑轉換為字串
PS C:\> Convert-Path ~
C:\Users\User01
此命令會將路徑轉換成目前提供者的主目錄,也就是 FileSystem 提供者,轉換為字串。
參數
-LiteralPath
指定要轉換的路徑,做為字串陣列。 LiteralPath 參數的值會與類型完全相同使用。 不會將任何字元解譯為通配符。 如果路徑包含逸出字元,請以單引弧括住它。 單引號會告知 Windows PowerShell 不要將任何字元解譯為逸出序列。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | PSPath |
參數集
LiteralPath
| Position: | Named |
| 必要: | True |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-Path
指定要轉換的 Windows PowerShell 路徑。
參數屬性
| 類型: | String[] |
| 預設值: | None |
| 支援萬用字元: | False |
| 不要顯示: | False |
參數集
Path
| Position: | 0 |
| 必要: | True |
| 來自管線的值: | True |
| 來自管線按屬性名稱的值: | True |
| 來自剩餘引數的值: | False |
-UseTransaction
在作用中交易中包含 命令。 只有在交易進行中時,此參數才有效。 如需詳細資訊,請參閱 about_Transactions。
參數屬性
| 類型: | SwitchParameter |
| 預設值: | False |
| 支援萬用字元: | False |
| 不要顯示: | False |
| 別名: | usetx |
參數集
(All)
| Position: | Named |
| 必要: | False |
| 來自管線的值: | False |
| 來自管線按屬性名稱的值: | False |
| 來自剩餘引數的值: | False |
CommonParameters
此 Cmdlet 支援一般參數:-Debug、-ErrorAction、-ErrorVariable、-InformationAction、-InformationVariable、-OutBuffer、-OutVariable、-PipelineVariable、-ProgressAction、-Verbose、-WarningAction 和 -WarningVariable。 如需詳細資訊,請參閱 about_CommonParameters。
輸入
String
您可以將路徑管線傳送至此 Cmdlet,但不能使用常值路徑。
輸出
String
此 Cmdlet 會傳回包含已轉換路徑的字串。
備註
包含 Path 名詞的 Cmdlet 會操作路徑名稱,並以簡潔的格式傳回名稱,讓所有 Windows PowerShell 提供者都能解譯。 其設計用於您想要以特定格式顯示路徑名稱的所有或部分的程式和腳本中。 使用它們就像使用 Dirname、Normpath、Realpath、Join 或其他路徑操作工具一樣。
您可以使用路徑 Cmdlet 搭配數個提供者,包括 FileSystem、登錄和憑證提供者。
此 Cmdlet 的設計目的是要處理任何提供者所公開的數據。 若要列出工作階段中可用的提供者,請輸入
Get-PSProvider。 如需詳細資訊,請參閱about_Providers。