how can I determine if the Prepare disc for BitLocker Partition creation was successful ?

sooner or later you’ll need to know if the creation of the BitLocker Partition was successful, this script will aid you in doing so, simply place it in a sub-folder of your MDT Toolkit Files scripts folder and update that package to your distribution points once done. This helps you to detect if your Prepare disk for BitLocker (bdehdcfg.exe -target default -quiet -size 1000) step was successful or not, sometimes that step can fail if for example the dirty bit is set on your hard disc.

The script checks your partition layout and if it finds a partition which is approximately the same size as the size you specify in the script, it will assume that one is your BitLocker partition, note I said ‘assume’. In my environment we set all our BitLocker partitions to be 1GB in size so that we can stage the boot.wim image on that partition during a refresh, and so it’s easy to find the BitLocker partition.

Here’s the script – BitLocker_Partition.WSF and it looks for a partition approximately 1GB in size, change the partition size to suit your environment and you can unrem the Wscript.Echo to test it’s effectiveness. The script sets a variable called BitLocker_Partition to True if it detects that the partition is the same size as you specified.

<job id=”checkBitLockerPartition”>
<script language=”VBScript” src=”..\ZTIUtility.vbs”/>
<script language=”VBScript”>

Dim oShell
Set oShell = CreateObject(“WScript.Shell”)
oEnvironment.Item(“BitLocker_Partition”) = False

strComputer = “.”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2”)
Set colDisks = objWMIService.ExecQuery _
(“Select * from Win32_diskpartition”)

Dim PartSize

For Each objDisk in colDisks
PartSize = (objDisk.Size / 1024 /1024)
‘Wscript.Echo “Disk Size: ” & PartSize
if PartSize > 990 and PartSize < 1010  then
oEnvironment.Item(“BitLocker_Partition”) = True
‘Wscript.Echo “Found 1000Mb partition – possibly BitLocker”
End if
Next

</script>
</job>

To use the script create a Run Command Line step in your task sequence which runs the script as follows:-

cscript.exe “%scriptroot%\BitLocker\BitLocker_Partition.WSF”

this sets our BitLocker_Partition variable to True if it finds a matching partition based on your settings and if the variable is set to true, you can create actions/groups to deal with it accordingly based on that result,

cheers

niall

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.