diff --git a/src/Microsoft.WSMan.Management/ConfigProvider.cs b/src/Microsoft.WSMan.Management/ConfigProvider.cs index 907c0f49af..bc6b961adc 100644 --- a/src/Microsoft.WSMan.Management/ConfigProvider.cs +++ b/src/Microsoft.WSMan.Management/ConfigProvider.cs @@ -1446,6 +1446,11 @@ namespace Microsoft.WSMan.Management // Get the wsman host name to find the session object string host = GetHostName(path); + if (string.IsNullOrEmpty(host)) + { + return false; + } + string WsManURI = NormalizePath(path, host); lock (WSManHelper.AutoSession) diff --git a/test/powershell/Modules/Microsoft.WSMan.Management/ConfigProvider.Tests.ps1 b/test/powershell/Modules/Microsoft.WSMan.Management/ConfigProvider.Tests.ps1 index 7c23de92bf..0391c217f4 100644 --- a/test/powershell/Modules/Microsoft.WSMan.Management/ConfigProvider.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.WSMan.Management/ConfigProvider.Tests.ps1 @@ -77,6 +77,10 @@ Describe "WSMan Config Provider" -Tag Feature,RequireAdminOnWindows { } } } + + It "Container check works" { + Test-Path wsman:\foo -PathType container | Should -BeFalse + } } Context "Get-Item tests" {