src/_Internals/Resolve-XrmPathInternal.ps1
|
<# Full file system path of a path given to a command: relative to the PowerShell location ($PWD), with ~ and PowerShell drives resolved. .NET methods (System.IO, COM objects such as Excel) resolve a relative path from the folder of the process, which Set-Location does not change: after a Set-Location, files were read or written in the wrong place (M25). The path does not have to exist and wildcards are not expanded. When the current location is not a folder (registry, Env:), relative to the last file system location. #> function Resolve-XrmPathInternal { [CmdletBinding()] [OutputType([String])] param( [Parameter(Mandatory = $true)] [AllowEmptyString()] [AllowNull()] [String] $Path ) if ([string]::IsNullOrWhiteSpace($Path)) { return $Path; } $provider = $null; $drive = $null; $resolvedPath = $PSCmdlet.SessionState.Path.GetUnresolvedProviderPathFromPSPath($Path, [ref]$provider, [ref]$drive); if ($provider.Name -ne "FileSystem") { $resolvedPath = [System.IO.Path]::Combine($PSCmdlet.SessionState.Path.CurrentFileSystemLocation.ProviderPath, $Path); } # Normalizes ".." and the separators; an absolute path no longer depends on the folder of the process [System.IO.Path]::GetFullPath($resolvedPath); } |