Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4817,6 +4817,13 @@ protected override string GetParentPath(string path, string root)
{
parentPath = EnsureDriveIsRooted(parentPath);
}
#if !UNIX
else if (parentPath.Equals(StringLiterals.DefaultPathSeparatorString, StringComparison.Ordinal))
{
// make sure we return two backslashes so it still results in a UNC path
parentPath = "\\\\";
}
#endif
return parentPath;
} // GetParentPath

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1301,3 +1301,24 @@ Describe "Extended FileSystem Path/Location Cmdlet Provider Tests" -Tags "Featur
}
}
}

Describe "UNC paths" -Tags 'CI' {
It "Can Get-ChildItems from a UNC location using <cmdlet>" -Skip:(!$IsWindows) -TestCases @(
@{cmdlet="Push-Location"},
@{cmdlet="Set-Location"}
) {
param($cmdlet)
$originalLocation = Get-Location
try {
$systemDrive = ($env:SystemDrive).Replace(":","$")
$testPath = Join-Path "\\localhost" $systemDrive
& $cmdlet $testPath
Get-Location | Should BeExactly "Microsoft.PowerShell.Core\FileSystem::$testPath"
$children = { Get-ChildItem -ErrorAction Stop } | Should Not Throw
$children.Count | Should BeGreaterThan 0
}
finally {
Set-Location $originalLocation
}
}
}