다음을 통해 공유


Convert-Path

Converts a path from a PowerShell path to a PowerShell provider path.

구문

Path (기본값)

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

LiteralPath

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

Description

The Convert-Path cmdlet converts a path from a PowerShell path to a PowerShell provider path.

예제

Example 1: Convert the working directory to a standard file system path

This example converts the current working directory, which is represented by a dot (.), to a standard FileSystem path.

PS C:\> Convert-Path .
C:\

Example 2: Convert a provider path to a standard registry path

This example converts the PowerShell provider path to a standard registry path.

PS C:\> Convert-Path HKLM:\Software\Microsoft
HKEY_LOCAL_MACHINE\Software\Microsoft

Example 3: Convert a path to a string

This example converts the path to the home directory of the current provider, which is the FileSystem provider, to a string.

PS C:\> Convert-Path ~
C:\Users\User01

Example 4: Convert paths for hidden items

By default, Convert-Path does not return hidden items. This example uses the Force parameter to find hidden items. The Get-Item command confirms that the .git folder is hidden. Using Convert-Path without the Force parameter returns only the visible items. Adding the Force parameter returns all items, including hidden items.

PS> Get-Item .git -Force

    Directory: D:\Git\PS-Docs\PowerShell-Docs

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d--h-           9/25/2024  4:46 PM                .git

PS> Convert-Path .git*
D:\Git\PS-Docs\PowerShell-Docs\.github
D:\Git\PS-Docs\PowerShell-Docs\.gitattributes
D:\Git\PS-Docs\PowerShell-Docs\.gitignore

PS> Convert-Path .git* -Force
D:\Git\PS-Docs\PowerShell-Docs\.git
D:\Git\PS-Docs\PowerShell-Docs\.github
D:\Git\PS-Docs\PowerShell-Docs\.gitattributes
D:\Git\PS-Docs\PowerShell-Docs\.gitignore

매개 변수

-Force

Allows the cmdlet to get items that otherwise can't be accessed by the user, such as hidden or system files. The Force parameter doesn't override security restrictions. Implementation varies among providers. For more information, see about_Providers.

This parameter was added in PowerShell 7.5-preview.5.

매개 변수 속성

형식:SwitchParameter
Default value:False
와일드카드 지원:False
DontShow:False

매개 변수 집합

(All)
Position:Named
필수:False
파이프라인의 값:False
속성 이름별 파이프라인의 값:False
나머지 인수의 값:False

-LiteralPath

Specifies, as a string array, the path to be converted. The value of the LiteralPath parameter is used exactly as it's typed. No characters are interpreted as wildcards. If the path includes escape characters, enclose it in single quotation marks. Single quotation marks tell PowerShell not to interpret any characters as escape sequences.

For more information, see about_Quoting_Rules.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:False
DontShow:False
별칭:PSPath, LP

매개 변수 집합

LiteralPath
Position:Named
필수:True
파이프라인의 값:False
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

-Path

Specifies the PowerShell path to be converted.

매개 변수 속성

형식:

String[]

Default value:None
와일드카드 지원:True
DontShow:False

매개 변수 집합

Path
Position:0
필수:True
파이프라인의 값:True
속성 이름별 파이프라인의 값:True
나머지 인수의 값:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

입력

String

You can pipe a path, but not a literal path, to this cmdlet.

출력

String

This cmdlet returns a string that contains the converted path.

참고

PowerShell includes the following aliases for Convert-Path:

  • All platforms:
    • cvpa

The cmdlets that contain the Path noun manipulate path names and return the names in a concise format that all PowerShell providers can interpret. They're designed for use in programs and scripts where you want to display all or part of a path in a particular format. Use them like you would use Dirname, Normpath, Realpath, Join, or other path manipulators.

You can use the path cmdlets with several providers, including the FileSystem, Registry, and Certificate providers.

This cmdlet is designed to work with the data exposed by any provider. To list the providers available in your session, type Get-PSProvider. For more information, see about_Providers.

Convert-Path only converts existing paths. It can't be used to convert a ___location that doesn't exist yet.