From 1cf4da15c8e132d2c273990c31ceb617720d1352 Mon Sep 17 00:00:00 2001 From: Mike Nothhard Date: Fri, 28 Jun 2019 09:58:59 -0400 Subject: [PATCH] Corrected Get-WindowsOptionalFeature logic for client OS. --- Misc/xBitlockerCommon.psm1 | 4 ++-- Tests/Unit/xBitlockerCommon.tests.ps1 | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Misc/xBitlockerCommon.psm1 b/Misc/xBitlockerCommon.psm1 index f31c7e5..fc8edcb 100644 --- a/Misc/xBitlockerCommon.psm1 +++ b/Misc/xBitlockerCommon.psm1 @@ -790,8 +790,8 @@ function Assert-HasPrereqsForBitlocker if ((Get-OSEdition) -like 'Client') { - $blFeature = Get-WindowsOptionalFeature BitLocker - if ($blFeature.InstallState -ne 'Installed') + $blFeature = Get-WindowsOptionalFeature -Online -FeatureName 'BitLocker' + if ($blFeature.State -ne 'Enabled') { $hasAllPreReqs = $false Write-Error 'The Bitlocker feature needs to be installed before the xBitlocker module can be used' diff --git a/Tests/Unit/xBitlockerCommon.tests.ps1 b/Tests/Unit/xBitlockerCommon.tests.ps1 index ce6ccb3..1e3036a 100644 --- a/Tests/Unit/xBitlockerCommon.tests.ps1 +++ b/Tests/Unit/xBitlockerCommon.tests.ps1 @@ -309,6 +309,8 @@ try Mock -CommandName Get-WindowsOptionalFeature -MockWith { param ( + [switch] + $online = $false, [string] $FeatureName ) @@ -316,7 +318,7 @@ try return @{ DisplayName = $FeatureName Name = $FeatureName - InstallState = 'Installed' + State = 'Enabled' } }