Skip to content

Commit 609e54d

Browse files
MartinVokurekjohlju
authored andcommitted
Fix for Issues #10 and #11 (#17)
- Fixed issue which caused xBLAutoBitlocker to incorrectly detect Fixed vs Removable volumes (issue #11). - Fixed issue which made xBLAutoBitlocker unable to encrypt volumes with drive letters assigned (issue #10).
1 parent 3a48bcf commit 609e54d

File tree

3 files changed

+401
-7
lines changed

3 files changed

+401
-7
lines changed

DSCResources/MSFT_xBLAutoBitlocker/MSFT_xBLAutoBitlocker.psm1

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ function Get-TargetResource
7070
$UsedSpaceOnly
7171
)
7272

73-
#Load helper module Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
73+
#Load helper module
74+
Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
7475

7576
CheckForPreReqs
7677

@@ -151,8 +152,9 @@ function Set-TargetResource
151152
[System.Boolean]
152153
$UsedSpaceOnly
153154
)
154-
155-
#Load helper module Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
155+
156+
#Load helper module
157+
Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
156158

157159
CheckForPreReqs
158160

@@ -254,7 +256,8 @@ function Test-TargetResource
254256
$UsedSpaceOnly
255257
)
256258

257-
#Load helper module Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
259+
#Load helper module
260+
Import-Module "$((Get-Item -LiteralPath "$($PSScriptRoot)").Parent.Parent.FullName)\Misc\xBitlockerCommon.psm1" -Verbose:0
258261

259262
CheckForPreReqs
260263

@@ -372,10 +375,35 @@ function GetAutoBitlockerStatus
372375
{
373376
[Hashtable]$returnValue = @{}
374377

378+
# Convert DriveType into values returned by Win32_EncryptableVolume.VolumeType
379+
switch ($DriveType)
380+
{
381+
'Fixed'
382+
{
383+
$driveTypeValue = 1
384+
}
385+
'Removable'
386+
{
387+
$driveTypeValue = 2
388+
}
389+
}
390+
375391
foreach ($blv in $allBlvs)
376392
{
377393
$vol = $null
378-
$vol = Get-Volume -Path $blv.MountPoint -ErrorAction SilentlyContinue | where {$_.DriveType -like $DriveType}
394+
395+
$encryptableVolumes = Get-CimInstance -Namespace 'root\cimv2\security\microsoftvolumeencryption' -Class Win32_Encryptablevolume -ErrorAction SilentlyContinue
396+
397+
if (Split-Path -Path $blv.MountPoint -IsAbsolute)
398+
{
399+
# MountPoint is a Drive Letter
400+
$vol = $encryptableVolumes | Where-Object {($_.DriveLetter -eq $blv.Mountpoint) -and ($_.VolumeType -eq $driveTypeValue)}
401+
}
402+
else
403+
{
404+
# MountPoint is a path
405+
$vol = $encryptableVolumes | Where-Object {($_.DeviceID -eq $blv.Mountpoint) -and ($_.VolumeType -eq $driveTypeValue)}
406+
}
379407

380408
if ($vol -ne $null)
381409
{

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ It does not work on Operating System drives.
5959
**xBLAutoBitlocker** has the following properties.
6060
Where no description is listed, properties correspond directly to [Enable-Bitlocker](http://technet.microsoft.com/en-us/library/jj649837.aspx) parameters.
6161

62-
* *DriveType:The type of volume, as reported by Get-Volume, to auto apply Bitlocker to
62+
* *DriveType:The type of volume to auto apply Bitlocker to. Valid values are "Fixed" or "Removable"
6363
* *PrimaryProtector:The primary protector type to be used for AutoBitlocker.
6464
Valid values are: "AdAccountOrGroupProtector", "PasswordProtector", "Pin", "RecoveryKeyProtector", "RecoveryPasswordProtector", "StartupKeyProtector", or "TpmProtector"
6565
* MinDiskCapacityGB:If specified, only disks this size or greater will auto apply Bitlocker
@@ -132,7 +132,8 @@ Defaults to false.
132132
* Added `PowerShellVersion = '4.0'`, and updated copyright information, in the
133133
module manifest.
134134
* Fixed issue which caused Test to incorrectly succeed on fully decrypted volumes when correct Key Protectors were present ([issue #13](https://github.com/PowerShell/xBitlocker/issues/13))
135-
135+
* Fixed issue which caused xBLAutoBitlocker to incorrectly detect Fixed vs Removable volumes. ([issue #11](https://github.com/PowerShell/xBitlocker/issues/11))
136+
* Fixed issue which made xBLAutoBitlocker unable to encrypt volumes with drive letters assigned. ([issue #10](https://github.com/PowerShell/xBitlocker/issues/10))
136137

137138
### 1.1.0.0
138139

0 commit comments

Comments
 (0)