PowerShell: Path Expansion

By Xah Lee. Date: . Last updated: .

Path Expansion

Some characters have special meaning in the value of Path parameter.

Path is expanded to fullpath or multiple paths.

Double quoted path goes thru String Expansion first, then go thru path expansion. To not go thru path expansion, use parameter LiteralPath .

Get Expanded Path Value

To see what a given path expand to, use Resolve-Path.


Resolves the wildcard characters in a path, prints result.

return a single object of PathInfo, or array of it. (return a string or array of string if Relative parameter is used.)

$x = Resolve-Path ~/
Write-Host $x
# C:\Users\xah
$x = Resolve-Path "~/Documents/*"

Write-Host $x -separator "`n"

C:\Users\xah\Documents\Sound recordings
C:\Users\xah\Documents\Wolfram Mathematica

PowerShell Path