Windows 7: Automate BitLocker deployment for notebooks
BitLocker provides full disk encryption in the Ultimate and Enterprise editions of Windows 7. During a Windows 7 migration project, I used it to replace the third-party disk encryption application Safeboot. Enabling BitLocker on one system was straightforward; the challenges for the enterprise deployment were:
- Prepare the Active Directory schema for BitLocker and TPM attributes.
- Configure the required Computer Configuration settings in Group Policy Objects.
- Activate and/or enable the TPM security chip during Windows 7 installation.
- Automate recovery-key backup and system-drive encryption during Windows 7 post-installation configuration.
The first two points required planning and carrying out changes to the Active Directory forest and linking the Group Policy Objects. I addressed TPM activation by changing the system BIOS during the first boot, before installing Windows 7.
The most challenging part was creating a script to enable BitLocker after Windows 7 was installed. We used the same thick image for notebooks and desktops. During my research, I found a sample script that automates BitLocker deployment through the BitLocker WMI interfaces.
The EnableBitLocker.vbs script gave me a starting point, but I still needed several additional steps to complete the encryption process.
Enable BitLocker during deployment
Before creating the script, I set these objectives:
- The script should only run on notebook models
- The script should write log files for troubleshooting and analysis
- The script should work with all installed MUI languages on the thick image
- The script should integrate with a Sysprep answer file.
The thick image included several MUI packs. During the pilot, EnableBitLocker.vbs failed when the de-DE German MUI language was used. I worked around this by setting the local Administrator account's preferred language to English.
Enable-notebook-bitlocker.vbs
Create a text file named Enable-notebook-bitlocker.vbs in C:\Deployment, and copy EnableBitLocker.vbs to the same folder.
| |
I will not go through every VBScript detail, but these are the main parts:
EnableBitLocker.vbs needs to run twice:
- Enable and activate the TPM in Windows.
- Take ownership of the TPM and reset its password, create a recovery password, save it to Active Directory and start BitLocker drive encryption.
The first run of EnableBitLocker.vbs reboots the system. In the oobeSystem Sysprep phase, I configured Administrator autologon for two sign-ins. At the first sign-in, a PowerShell script started through FirstLogonCommands SynchronousCommand ran Enable-notebook-bitlocker.vbs. After the reboot, RunOnce started the second part of the PowerShell script, which ran Enable-notebook-bitlocker.vbs again.
I use Sysprep and an answer file after the Windows 7 image has loaded. These steps can also be integrated with a software deployment solution such as SCCM.
Run the script twice, using a separate log file for each run:
| |
After a week of research, development and testing, I had automated the BitLocker encryption process. Notebook encryption took between 2 and 5 hours, depending on disk size and the age of the hardware.
References
- Technet - Enabling BitLocker by Using a WMI Script
- BitLocker Deployment Sample Resources
- Technet - Backing Up BitLocker and TPM Recovery Information to AD DS
- Technet - Enabling BitLocker by Using the Command Line
5 comments
Comments from the original WordPress site, kept read-only.
great article, helped out a lot!
Thanks for a great blog post. I love the funny remarks.
What would the power shell command look like to add as a sequense in the oobe pass for the unattend.xml? or does it go before that? Please resond I know this post is several months old but htis is what we need ASAP!
Thank you for the help in advance
Gary
Hi Gary,
Thanks for being on my blog and reading this post. I am looking forward for your results based on this post.
Actually the answer is already posted in this post.
Create a PowerShell script and have the following line is run:
cscript c:\Deployment\enable-notebook-bitlocker.vbs /log:c:\Deployment\1st-boot-EnableBitLocker.log
I have implemented this at the initial run within the OOBE phase of Sysprep.
To recap. Withing oobeSystem pass I have set the following commands:
-firstlogoncommands-
-synchronouscommand wcm:action="add"-
-commandline-%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe -Command "set-executionpolicy RemoteSigned -Force"-/commandline-
-description-Sets Powershell to RemoteSigned-/description-
-order-1-/order-
-requiresuserinput-false-/requiresuserinput-
-/synchronouscommand-
-synchronouscommand wcm:action="add"-
-order-2-/order-
-commandline-%SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe C:\Scripts\3rd-boot.ps1-/commandline-
-description-Add's Computer to domain and start Bitlocker-/description-
-requiresuserinput-false-/requiresuserinput-
-/synchronouscommand-
-/firstlogoncommands-
Within the 3rd-boot.ps1 file paste that VBScript line. Make sure to have autologon set to 1 time in addition where the script can run one time more to start the encryption process.
I hope this will help you on the way.
So If I understand you correctly, I am adding 3 additional syncronouscommands 2 for powershell commands and the 3rd runs the enablebitlocker.vbs script within a powershell script, Correct? I have 4 SyncronousCommands now in the OOBE for the 1st Administrator Autologon 1. autoactivates windows 2. runs the /ato switch for activation, 3. joind the computer to the domain via script where tech choses the ou, and 4. set the desktop background. My Autologons for Administrator with this process would increase to 4 to include the bitlocker process, and would the subsiquent Auto Logons run the powershell commands fine? Let me know as soon as you can.
Thank you