From 44e377525b77a2cb1bbbf2c5bd64ac05d684c030 Mon Sep 17 00:00:00 2001 From: Steve Lee Date: Tue, 18 Jul 2017 10:07:05 -0700 Subject: [PATCH] Register-PSSessionConfiguration fails if SesionConfig folder doesn't exist (#4271) --- .../engine/remoting/commands/CustomShellCommands.cs | 8 +++++++- .../Implicit.Remoting.Tests.ps1 | 5 ++++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs index a342219a85..a544c37660 100644 --- a/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs +++ b/src/System.Management.Automation/engine/remoting/commands/CustomShellCommands.cs @@ -964,7 +964,13 @@ else } } - string destPath = System.IO.Path.Combine(Utils.DefaultPowerShellAppBase, "SessionConfig", + string destFolder = System.IO.Path.Combine(Utils.DefaultPowerShellAppBase, "SessionConfig"); + if (!Directory.Exists(destFolder)) + { + Directory.CreateDirectory(destFolder); + } + + string destPath = System.IO.Path.Combine(destFolder, shellName + "_" + sessionGuid.ToString() + StringLiterals.PowerShellDISCFileExtension); if (string.Equals(ProcessorArchitecture, "x86", StringComparison.OrdinalIgnoreCase)) { diff --git a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 index 72247041c8..a5a4d27223 100644 --- a/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 +++ b/test/powershell/Modules/Microsoft.PowerShell.Utility/Implicit.Remoting.Tests.ps1 @@ -2108,7 +2108,10 @@ Describe "Import-PSSession on Restricted Session" -tags "Feature","RequireAdminO } } - It "Verifies that Import-PSSession works on a restricted session" { + # Blocked by https://github.com/PowerShell/PowerShell/issues/4275 + # Need a way to created restricted endpoint based on a different endpoint other than microsoft.powershell which points + # to Windows PowerShell 5.1 + It "Verifies that Import-PSSession works on a restricted session" -Pending { $errorVariable = $null Import-PSSession -Session $session -AllowClobber -ErrorVariable $errorVariable