@@ -583,7 +583,13 @@ function InstallContainer
583
583
}
584
584
else
585
585
{
586
- $containerExists = Get-WindowsFeature - Name Containers
586
+ switch (Get-wmiobject - class win32_operatingsystem | select-object - ExpandProperty Caption ){
587
+ ' Microsoft Windows 10' {
588
+ $containerExists = Get-WindowsOptionalFeature - Online - FeatureName Containers |
589
+ Select-object - Property * , @ {name = ' Installed' ;expression = {$_.State -eq ' Enabled' }}
590
+ }
591
+ Default {$containerExists = Get-WindowsFeature - Name Containers}
592
+ }
587
593
if ($containerExists -and $containerExists.Installed )
588
594
{
589
595
Write-Verbose " Containers feature is already installed. Skipping the install."
@@ -592,7 +598,10 @@ function InstallContainer
592
598
else
593
599
{
594
600
Write-Verbose " Installing Containers..."
595
- $null = Install-WindowsFeature containers
601
+ switch (Get-wmiobject - class win32_operatingsystem | select-object - ExpandProperty Caption ){
602
+ ' Microsoft Windows 10' {$null = Enable-WindowsOptionalFeature - FeatureName Containers}
603
+ Default {$null = Install-WindowsFeature containers}
604
+ }
596
605
$script :restartRequired = $true
597
606
}
598
607
}
@@ -608,7 +617,11 @@ function UninstallContainer
608
617
}
609
618
else
610
619
{
611
- $null = Uninstall-WindowsFeature containers
620
+ switch (Get-wmiobject - class win32_operatingsystem | select-object - ExpandProperty Caption ){
621
+ ' Microsoft Windows 10' {$null = Disable-WindowsOptionalFeature - FeatureName Containers}
622
+ Default {$null = Uninstall-WindowsFeature containers }
623
+ }
624
+
612
625
}
613
626
}
614
627
0 commit comments