Jump to content


Configuring BitLocker in Intune - Part 2. Automating Encryption

Recommended Posts

Thanks for this script/ solution. Thanks to this I learned a lot about how to do BitLocker with PowerShell from Intune MDM. I've added some functionality and made some fixes and design changes, but can't release all the code here due to the fact that I've done this for my company, and it's their IP.

That being said, I'd like to share a fix to one part that failed for me some times: Fetching the certificate for uploading recovery password to Azure AD using REST.
I rewrote it to this, might be usefull for others:

# Get the AAD Machine Certificate
$Certificate           = $([array]$(Get-ChildItem -Path 'Certificate::LocalMachine\My').Where{$_.'Issuer' -match 'CN=MS-Organization-Access'})
$CertificateThumbprint = [string]$($Certificate | Select-Object -ExpandProperty 'Thumbprint')
$CertificateSubject    = [string]$([string]$($Certificate | Select-Object -ExpandProperty 'Subject').Replace('CN=',''))
# Get tenant domain name from registry
$TenantDomain = [string]$([string]$(Get-ItemProperty -Path ('Registry::HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\CloudDomainJoin\JoinInfo\{0}' -f ($CertificateThumbprint)) -Name 'UserEmail' | Select-Object -ExpandProperty 'UserEmail').Split('@')[-1])


Offtopic: How do I set a profile picture? I've searched the forum and Google-ed it too.

Edited by olavrb
  • Like 1

Share this post

Link to post
Share on other sites

What happens if the target endpoint has more than one fixed drive? It appears to work fine for the OS Drive, but the secondary drive never attempts to be encrypted. Just curious if there is a way to encrypt all fixed drives (obviously not USB / external storage that happens to be attached). Thanks!

Share this post

Link to post
Share on other sites

2 questions.


1.I just tested this script on a user's pc.  The script pushed fine, and ran and encyrpted the drive, but the recovery key is not in inute/AzureAD.  What can I do to troubleshoot this?

2. If I push this to a user who already has their drive encrypted(different user now) but is only now joining their pc to azureAD/Intune.  Will the script still run and detect that the drive is encrypted and sync the recovery key to intune/AzureAD?





Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.