Skip to content

Commit fa6c7d1

Browse files
committed
Merge pull request #2 from PowerShell/dev
Update to version 1.0.1.1 from PSGallery
2 parents 23da51c + e22dc8f commit fa6c7d1

File tree

11 files changed

+351
-385
lines changed

11 files changed

+351
-385
lines changed

DSCResources/MSFT_xBLAutoBitlocker/MSFT_xBLAutoBitlocker.psm1

Lines changed: 113 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ function Get-TargetResource
1212
[System.Int32]
1313
$MinDiskCapacityGB,
1414

15-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
15+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
1616
[parameter(Mandatory = $true)]
1717
[System.String]
1818
$PrimaryProtector,
@@ -74,36 +74,8 @@ function Get-TargetResource
7474

7575
CheckForPreReqs
7676

77-
#First get all Bitlocker Volumes of type Data
78-
$allBlvs = Get-BitLockerVolume | where {$_.VolumeType -eq "Data"}
79-
80-
#Filter on size if it was specified
81-
if ($PSBoundParameters.ContainsKey("MinDiskCapacityGB"))
82-
{
83-
$allBlvs = $allBlvs | where {$_.CapacityGB -ge $MinDiskCapacityGB}
84-
}
85-
86-
#Now find disks of the appropriate drive type, and add them to the collection
87-
if ($allBlvs -ne $null)
88-
{
89-
[Hashtable]$returnValue = @{}
90-
91-
foreach ($blv in $allBlvs)
92-
{
93-
$vol = $null
94-
$vol = Get-Volume -Path $blv.MountPoint -ErrorAction SilentlyContinue | where {$_.DriveType -like $DriveType}
95-
96-
if ($vol -ne $null)
97-
{
98-
[Hashtable]$props = @{
99-
VolumeStatus = $blv.VolumeStatus
100-
KeyProtectors = $blv.KeyProtector
101-
EncryptionMethod = $blv.EncryptionMethod
102-
}
103-
104-
$returnValue.Add($blv.MountPoint, $props)
105-
}
106-
}
77+
$returnValue = @{
78+
DriveType = $DriveType
10779
}
10880

10981
$returnValue
@@ -122,7 +94,7 @@ function Set-TargetResource
12294
[System.Int32]
12395
$MinDiskCapacityGB,
12496

125-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
97+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
12698
[parameter(Mandatory = $true)]
12799
[System.String]
128100
$PrimaryProtector,
@@ -184,7 +156,7 @@ function Set-TargetResource
184156

185157
CheckForPreReqs
186158

187-
$autoBlVols = Get-TargetResource @PSBoundParameters
159+
$autoBlVols = GetAutoBitlockerStatus @PSBoundParameters
188160

189161
if ($autoBlVols -eq $null)
190162
{
@@ -210,7 +182,6 @@ function Set-TargetResource
210182
}
211183
}
212184

213-
214185
function Test-TargetResource
215186
{
216187
[CmdletBinding()]
@@ -225,7 +196,7 @@ function Test-TargetResource
225196
[System.Int32]
226197
$MinDiskCapacityGB,
227198

228-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
199+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
229200
[parameter(Mandatory = $true)]
230201
[System.String]
231202
$PrimaryProtector,
@@ -287,7 +258,7 @@ function Test-TargetResource
287258

288259
CheckForPreReqs
289260

290-
$autoBlVols = Get-TargetResource @PSBoundParameters
261+
$autoBlVols = GetAutoBitlockerStatus @PSBoundParameters
291262

292263
if ($autoBlVols -eq $null)
293264
{
@@ -315,8 +286,113 @@ function Test-TargetResource
315286
return $true
316287
}
317288

289+
function GetAutoBitlockerStatus
290+
{
291+
[CmdletBinding()]
292+
[OutputType([System.Collections.Hashtable])]
293+
param
294+
(
295+
[parameter(Mandatory = $true)]
296+
[ValidateSet("Fixed","Removable")]
297+
[System.String]
298+
$DriveType,
299+
300+
[System.Int32]
301+
$MinDiskCapacityGB,
318302

319-
Export-ModuleMember -Function *-TargetResource
303+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
304+
[parameter(Mandatory = $true)]
305+
[System.String]
306+
$PrimaryProtector,
307+
308+
[System.String]
309+
$AdAccountOrGroup,
310+
311+
[System.Boolean]
312+
$AdAccountOrGroupProtector,
313+
314+
[System.Boolean]
315+
$AutoUnlock = $false,
316+
317+
[ValidateSet("Aes128","Aes256")]
318+
[System.String]
319+
$EncryptionMethod,
320+
321+
[System.Boolean]
322+
$HardwareEncryption,
323+
324+
[System.Management.Automation.PSCredential]
325+
$Password,
326+
327+
[System.Boolean]
328+
$PasswordProtector,
329+
330+
[System.Management.Automation.PSCredential]
331+
$Pin,
332+
333+
[System.String]
334+
$RecoveryKeyPath,
335+
336+
[System.Boolean]
337+
$RecoveryKeyProtector,
338+
339+
[System.Boolean]
340+
$RecoveryPasswordProtector,
341+
342+
[System.Boolean]
343+
$Service,
344+
345+
[System.Boolean]
346+
$SkipHardwareTest,
347+
348+
[System.String]
349+
$StartupKeyPath,
350+
351+
[System.Boolean]
352+
$StartupKeyProtector,
353+
354+
[System.Boolean]
355+
$TpmProtector,
356+
357+
[System.Boolean]
358+
$UsedSpaceOnly
359+
)
360+
361+
#First get all Bitlocker Volumes of type Data
362+
$allBlvs = Get-BitLockerVolume | where {$_.VolumeType -eq "Data"}
363+
364+
#Filter on size if it was specified
365+
if ($PSBoundParameters.ContainsKey("MinDiskCapacityGB"))
366+
{
367+
$allBlvs = $allBlvs | where {$_.CapacityGB -ge $MinDiskCapacityGB}
368+
}
369+
370+
#Now find disks of the appropriate drive type, and add them to the collection
371+
if ($allBlvs -ne $null)
372+
{
373+
[Hashtable]$returnValue = @{}
374+
375+
foreach ($blv in $allBlvs)
376+
{
377+
$vol = $null
378+
$vol = Get-Volume -Path $blv.MountPoint -ErrorAction SilentlyContinue | where {$_.DriveType -like $DriveType}
320379

380+
if ($vol -ne $null)
381+
{
382+
[Hashtable]$props = @{
383+
VolumeStatus = $blv.VolumeStatus
384+
KeyProtectors = $blv.KeyProtector
385+
EncryptionMethod = $blv.EncryptionMethod
386+
}
387+
388+
$returnValue.Add($blv.MountPoint, $props)
389+
}
390+
}
391+
}
392+
393+
$returnValue
394+
}
395+
396+
Export-ModuleMember -Function *-TargetResource
321397

322398

DSCResources/MSFT_xBLAutoBitlocker/MSFT_xBLAutoBitlocker.schema.mof

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class MSFT_xBLAutoBitlocker : OMI_BaseResource
66

77
[Key, ValueMap{"Fixed","Removable"}, Values{"Fixed","Removable"}] String DriveType; //The type of volume, as reported by Get-Volume, to auto apply Bitlocker to
88
[Write] Sint32 MinDiskCapacityGB; //If specified, only disks this size or greater will auto apply Bitlocker
9-
[Required, ValueMap{"AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}, Values{"AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}] String PrimaryProtector;
9+
[Required, ValueMap{"PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}, Values{"PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}] String PrimaryProtector;
1010
[Write] Boolean AutoUnlock; //Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
1111

1212
//Remaing properties correspond directly to Enable-Bitlocker parameters
@@ -30,4 +30,3 @@ class MSFT_xBLAutoBitlocker : OMI_BaseResource
3030
};
3131

3232

33-

DSCResources/MSFT_xBLBitlocker/MSFT_xBLBitlocker.psm1

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function Get-TargetResource
88
[System.String]
99
$MountPoint,
1010

11-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
11+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
1212
[parameter(Mandatory = $true)]
1313
[System.String]
1414
$PrimaryProtector,
@@ -73,18 +73,10 @@ function Get-TargetResource
7373

7474
CheckForPreReqs
7575

76-
$blv = Get-BitLockerVolume -MountPoint $MountPoint -ErrorAction SilentlyContinue
77-
78-
if ($blv -ne $null)
79-
{
80-
$returnValue = @{
81-
MountPoint = $MountPoint
82-
VolumeStatus = $blv.VolumeStatus
83-
KeyProtectors = $blv.KeyProtector
84-
EncryptionMethod = $blv.EncryptionMethod
85-
}
76+
$returnValue = @{
77+
MountPoint = $MountPoint
8678
}
87-
79+
8880
$returnValue
8981
}
9082

@@ -98,7 +90,7 @@ function Set-TargetResource
9890
[System.String]
9991
$MountPoint,
10092

101-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
93+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
10294
[parameter(Mandatory = $true)]
10395
[System.String]
10496
$PrimaryProtector,
@@ -176,7 +168,7 @@ function Test-TargetResource
176168
[System.String]
177169
$MountPoint,
178170

179-
[ValidateSet("AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
171+
[ValidateSet("PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector")]
180172
[parameter(Mandatory = $true)]
181173
[System.String]
182174
$PrimaryProtector,
@@ -249,4 +241,3 @@ function Test-TargetResource
249241
Export-ModuleMember -Function *-TargetResource
250242

251243

252-

DSCResources/MSFT_xBLBitlocker/MSFT_xBLBitlocker.schema.mof

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
class MSFT_xBLBitlocker : OMI_BaseResource
44
{
55
[Key] String MountPoint; //The MountPoint name as reported in Get-BitLockerVolume
6-
[Required, ValueMap{"AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}, Values{"AdAccountOrGroupProtector","PasswordProtector","Pin","RecoveryKeyProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}] String PrimaryProtector; //The type of key protector that will be used as the primary key protector
6+
[Required, ValueMap{"PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}, Values{"PasswordProtector","RecoveryPasswordProtector","StartupKeyProtector","TpmProtector"}] String PrimaryProtector; //The type of key protector that will be used as the primary key protector
77
[Write] Boolean AutoUnlock; //Whether volumes should be enabled for auto unlock using Enable-BitlockerAutoUnlock
88
[Write] Boolean AllowImmediateReboot; //Whether the computer can be immediately rebooted after enabling Bitlocker on an OS drive. Defaults to false.
99

@@ -28,4 +28,3 @@ class MSFT_xBLBitlocker : OMI_BaseResource
2828
};
2929

3030

31-

DSCResources/MSFT_xBLTpm/MSFT_xBLTpm.psm1

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ function Get-TargetResource
1919
{
2020
$returnValue = @{
2121
Identity = $Identity
22-
TpmReady = $tpm.TpmReady
2322
}
2423
}
2524

@@ -59,18 +58,15 @@ function Set-TargetResource
5958
{
6059
if ($tpm.RestartRequired -eq $true)
6160
{
61+
$global:DSCMachineStatus = 1
62+
6263
if ($AllowImmediateReboot -eq $true)
6364
{
64-
Write-Verbose "Forcing an immediate reboot of the computer"
65+
Write-Verbose "Forcing an immediate reboot of the computer in 30 seconds"
6566

67+
Start-Sleep -Seconds 30
6668
Restart-Computer -Force
6769
}
68-
else
69-
{
70-
Write-Verbose "Setting DSCMachineStatus to 1"
71-
72-
$global:DSCMachineStatus = 1
73-
}
7470
}
7571
}
7672
else
@@ -120,4 +116,3 @@ function Test-TargetResource
120116
Export-ModuleMember -Function *-TargetResource
121117

122118

123-

DSCResources/MSFT_xBLTpm/MSFT_xBLTpm.schema.mof

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,3 @@ class MSFT_xBLTpm : OMI_BaseResource
99
};
1010

1111

12-

0 commit comments

Comments
 (0)