Search notes:

System.Management.Automation.PathIntrinsics (class)

Properties and Methods

Combine() Combines two strings with a provider specific path separator.
CurrentFileSystemLocation
CurrentLocation
CurrentProviderLocation() foreach ($p in get-psProvider){ "$p.name -> $($ExecutionContext.SessionState.Path.CurrentProviderLocation($p.name))" }
GetResolvedProviderPathFromProviderPath() Resolves a drive or provider qualified absolute or relative path that may contain wildcard characters into one or more provider-internal paths.
GetResolvedProviderPathFromPSPath() Resolves a drive or provider qualified absolute or relative path that may contain wildcard characters into one or more provider-internal paths.
GetResolvedPSPathFromPSPath() Resolves a drive or provider qualified absolute or relative path that may contain wildcard characters into one or more absolute drive or provider qualified paths
GetUnresolvedProviderPathFromPSPath() Converts a drive or provider qualified absolute or relative path that may contain wildcard characters into one a provider-internal path still containing the wildcard characters.
IsProviderQualified()
IsPSAbsolute()
IsValid()
LocationStack()
NormalizeRelativePath()
ParseChildName()
ParseParent()
PopLocation()
PushCurrentLocation()
SetDefaultLocationStack()
SetLocation()

PowerShell

In PowerShell, an instance to System.Management.Automation.PathIntrinsics is returned by the expression
$ExecutionContext.SessionState.Path
$ExecutionContext.SessionState.Path.CurrentLocation
$ExecutionContext.SessionState.Path.CurrentFileSystemLocation
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath(".\nonexist\foo.txt")

CurrentProviderLocation

Show the current location of providers:
$ExecutionContext.SessionState.Path.CurrentProviderLocation('Registry')
$ExecutionContext.SessionState.Path.CurrentProviderLocation('FileSystem')

Combine

$ExecutionContext.SessionState.Path.Combine('foo\..', 'bar\baz') evaluates to foo\..\bar\baz.

GetResolvedPSPathFromPSPath

GetResolvedPSPathFromPSPath returns an absolute path that points to the same directory or file that the relative or absolute path that was passed as argument points to if that file or directory exists, otherwise, it throws an error:
$ExecutionContext.SessionState.Path.GetResolvedPSPathFromPSPath('../../xyz')

GetUnresolvedProviderPathFromPSPath

GetUnresolvedProviderPathFromPSPath always returns an absolute path, even if the file or directory does not exist:
$ExecutionContext.SessionState.Path.GetUnresolvedProviderPathFromPSPath('path/that/does/../not/exist.txt')

NormalizeRelativePath

$ExecutionContext.SessionState.Path.NormalizeRelativePath("$home/foo/bar", $home)

ParseChildName / ParseParent

ParseChildName

$ExecutionContext.SessionState.Path.ParseChildName('child/grand-child/grand-grand-child') evaluates to grand-grand-child.

ParseParent

ParseParent($dir, $root) returns the parent directory of $dir.
As per documentation, $root is optional and allows to set the top-most directory of the returned directory. If this functionality is not required, this parameter must be set to $null.
$ExecutionContext.SessionState.Path.ParseParent("$home/../maria/foo.txt", $home) evaluates to C:\Users\rene\..\maria.
$ExecutionContext.SessionState.Path.ParseParent("C:\Users\maria\foo.txt", $home) evaluates to C:\Users\maria.
$ExecutionContext.SessionState.Path.ParseParent("$home/../../maria/foo.txt", $null) evaluates to C:\Users\rene\..\..\maria.

Location stack

$ExecutionContext.SessionState.Path.PushLocation('xyz')
$ExecutionContext.SessionState.Path.SetDefaultLocationStack('xyz')
$ExecutionContext.SessionState.Path.LocationStack('xyz')
$ExecutionContext.SessionState.Path.PopLocation('xyz')

$ExecutionContext.SessionState.Path.SetLocation(…)

See also

System.Management.Automation.SessionState
The PowerShell cmdlet resolve-path

Index