diff --git a/src/System.Management.Automation/engine/Utils.cs b/src/System.Management.Automation/engine/Utils.cs index c8557d91d7b..5483b870db3 100644 --- a/src/System.Management.Automation/engine/Utils.cs +++ b/src/System.Management.Automation/engine/Utils.cs @@ -1260,8 +1260,19 @@ internal static bool PathIsUnc(string path) #if UNIX return false; #else + if (string.IsNullOrEmpty(path) || !path.StartsWith('\\')) + { + return false; + } + + // handle special cases like \\wsl$\ubuntu which isn't a UNC path, but we can say it is so the filesystemprovider can use it + if (path.StartsWith(@"\\wsl$", StringComparison.OrdinalIgnoreCase)) + { + return true; + } + Uri uri; - return !string.IsNullOrEmpty(path) && Uri.TryCreate(path, UriKind.Absolute, out uri) && uri.IsUnc; + return Uri.TryCreate(path, UriKind.Absolute, out uri) && uri.IsUnc; #endif }