Convert-Path

将路径从 Windows PowerShell 路径转换为 Windows PowerShell 提供程序路径。

语法

Convert-Path
       [-Path] <String[]>
       [-UseTransaction]
       [<CommonParameters>]
Convert-Path
       -LiteralPath <String[]>
       [-UseTransaction]
       [<CommonParameters>]

说明

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[]
别名:PSPath
Position:Named
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-Path

指定要转换的 Windows PowerShell 路径。

类型:String[]
Position:0
默认值:None
必需:True
接受管道输入:True
接受通配符:False

-UseTransaction

在活动事务中包含该命令。 此参数仅在事务正在进行时有效。 有关详细信息,请参阅about_Transactions。

类型:SwitchParameter
别名:usetx
Position:Named
默认值:False
必需:False
接受管道输入:False
接受通配符:False

输入

String

可以通过管道将路径(而不是文本路径)传递给此 cmdlet。

输出

String

此 cmdlet 返回包含转换路径的字符串。

备注

  • 包含 Path 名词的 cmdlet 操作路径名称,并返回所有 Windows PowerShell 提供程序可以解释的简洁格式的名称。 它们旨在用于要以特定格式显示路径名称的所有或部分的程序和脚本。 像使用 Dirname、Normpath、Realpath、Join 或其他路径操控器一样使用它们。

    可以将路径 cmdlet 与多个提供程序一起使用,包括 FileSystem、注册表和证书提供程序。

    此 cmdlet 旨在处理任何提供程序公开的数据。 若要列出会话中可用的提供程序,请键入 Get-PSProvider。 有关详细信息,请参阅about_Providers。