From a98c455fe18065ec63485fa4077f1d2109813593 Mon Sep 17 00:00:00 2001 From: Tristan Barcelon Date: Fri, 17 Aug 2018 03:12:37 +0000 Subject: [PATCH 1/2] Fix InstallContainer error when using DockerMSFTProvider on Windows 10 Fix InstallContainer error when using DockerMSFTProvider on Windows 10 --- DockerMsftProvider.psd1 | 2 +- DockerMsftProvider.psm1 | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DockerMsftProvider.psd1 b/DockerMsftProvider.psd1 index 4832e1d..5f8a007 100644 --- a/DockerMsftProvider.psd1 +++ b/DockerMsftProvider.psd1 @@ -12,7 +12,7 @@ RootModule = 'DockerMsftProvider.psm1' # Version number of this module. -ModuleVersion = '1.0.0.5' +ModuleVersion = '1.0.0.6' # ID used to uniquely identify this module GUID = '5beed3da-526b-47eb-9197-29c6a7214e4e' diff --git a/DockerMsftProvider.psm1 b/DockerMsftProvider.psm1 index 6f90964..463faeb 100644 --- a/DockerMsftProvider.psm1 +++ b/DockerMsftProvider.psm1 @@ -584,8 +584,9 @@ function InstallContainer } else { - switch(Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption ){ - 'Microsoft Windows 10' { + [string] $OSCaption = Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption + switch -WildCard ($OSCaption) { + 'Microsoft Windows 10*' { $containerExists = Get-WindowsOptionalFeature -Online -FeatureName Containers | Select-object -Property *,@{name='Installed';expression={$_.State -eq 'Enabled'}} } @@ -599,8 +600,8 @@ function InstallContainer else { Write-Verbose "Installing Containers..." - switch(Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption ){ - 'Microsoft Windows 10' {$null = Enable-WindowsOptionalFeature -FeatureName Containers} + switch -WildCard ($OSCaption) { + 'Microsoft Windows 10*' {$null = Enable-WindowsOptionalFeature -FeatureName Containers} Default {$null = Install-WindowsFeature containers} } $script:restartRequired = $true From 05de7e4ad3b8a6d64c4f34f4fb28792643c765dc Mon Sep 17 00:00:00 2001 From: Tristan Barcelon Date: Wed, 22 Aug 2018 20:41:30 -0400 Subject: [PATCH 2/2] fix UninstallContainer so it can uninstall correctly in Windows 10 client --- DockerMsftProvider.psm1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DockerMsftProvider.psm1 b/DockerMsftProvider.psm1 index 463faeb..499932c 100644 --- a/DockerMsftProvider.psm1 +++ b/DockerMsftProvider.psm1 @@ -619,9 +619,10 @@ function UninstallContainer } else { - switch(Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption ){ - 'Microsoft Windows 10' {$null = Disable-WindowsOptionalFeature -FeatureName Containers} - Default {$null = Uninstall-WindowsFeature containers } + [string] $OSCaption = Get-wmiobject -class win32_operatingsystem | select-object -ExpandProperty Caption + switch -WildCard ($OSCaption) { + 'Microsoft Windows 10*' {$null = Disable-WindowsOptionalFeature -FeatureName Containers} + Default {$null = Uninstall-WindowsFeature containers} } }