Skip to content

UNEN.nl – Tech, Automatisering & Fotografie

Tips, scripts en experimenten met Microsoft, Home Assistant en alles wat automatiseren leuk maakt.

Primary Menu
  • Algemeen
  • Fotografie
  • Home Assistant
  • Microsoft
  • Azure
  • Powershell
Light/Dark Button
  • Home
  • Powershell – πŸ” BitLocker automatisch controleren en inschakelen met PowerShell
  • Intune
  • Powershell

Powershell – πŸ” BitLocker automatisch controleren en inschakelen met PowerShell

Vincent van Unen 2026-03-11 (Last updated: 2026-03-11) 4 minutes read
ChatGPT Image Mar 11, 2026, 01_55_02 PM

Beveiliging van endpoints is tegenwoordig geen luxe meer, maar een noodzaak. Gelukkig helpt Microsoft BitLocker daarbij door schijven te versleutelen. Maar wat als BitLocker nog niet actief is op een apparaat? Of als de recovery key niet goed is opgeslagen?

Met dit PowerShell-script wordt dat automatisch gecontroleerd Γ©n opgelost. πŸš€

Het script controleert of BitLocker correct is ingesteld op een Windows-apparaat en voert waar nodig automatisch herstelacties uit. Ideaal voor beheer via Intune, beheerplatformen of handmatige deployments.


βš™οΈ Wat doet het script precies?

Het script voert meerdere controles uit om te garanderen dat BitLocker correct en veilig is geconfigureerd.

πŸ” Controle op TPM

Het script controleert eerst of er een TPM-chip aanwezig en klaar voor gebruik is. Zonder TPM kan BitLocker namelijk niet op de standaard veilige manier worden ingezet.

πŸ” BitLocker status controleren

Daarna wordt gecontroleerd of BitLocker al actief is op de systeemschijf.

Is BitLocker nog niet ingeschakeld?
Dan wordt de versleuteling automatisch gestart met XTS-AES-256 encryptie.

πŸ— Recovery key controleren

Een recovery key is essentieel wanneer toegang tot het systeem verloren dreigt te gaan. Het script controleert daarom of een Recovery Password Protector aanwezig is.

Ontbreekt deze? Dan wordt hij automatisch toegevoegd.

☁️ Backup naar Entra ID / Azure AD

Voor centraal beheer wordt de recovery key automatisch geback-upt naar Entra ID (Azure AD). Hierdoor kunnen beheerders de sleutel altijd terugvinden wanneer dat nodig is.

πŸ“ Logging en troubleshooting

Het script maakt uitgebreide logs met onder andere:

  • uitvoerende gebruiker
  • apparaatnaam
  • IP-adressen
  • encryptiestatus
  • foutmeldingen

Daarnaast wordt een transcriptbestand aangemaakt dat automatisch wordt gekopieerd naar de Intune Management Extension logs. Zo blijft troubleshooting eenvoudig.


πŸ’‘ Waarom dit handig is

In grotere omgevingen komt het regelmatig voor dat:

  • BitLocker niet is ingeschakeld
  • Recovery keys ontbreken
  • Keys niet naar Entra ID zijn geΓΌpload
  • TPM nog niet correct is geΓ―nitialiseerd

Dit script lost die problemen automatisch op en zorgt voor een consistente beveiligingsconfiguratie op alle apparaten.

Perfect dus voor gebruik als:

  • Intune remediation script
  • compliance fix
  • deployment controle
  • endpoint security automatisering

πŸ–₯ Ondersteunde systemen

Het script werkt op:

  • Windows 10 Pro
  • Windows 10 Enterprise
  • Windows 10 Education
  • Windows 11 Pro
  • Windows 11 Enterprise
  • Windows 11 Education

Uitvoering moet plaatsvinden als Administrator of SYSTEM.


πŸ’» Het PowerShell-script

param ([switch]$Silent)<#	
Remediation - BitLocker inschakelen en recovery key back-uppen
#>#region Script metadata
$ScriptAuthor = "Vincent van Unen"
$ScriptVersion = "1.1"
$ScriptChangeDate = "2026-03-09"
$ScriptCurrentUser = $env:UserName
$ScriptRunningDevice = $env:COMPUTERNAME
$CurrentDate = Get-Date -Format "yyyy-MM-dd"
$LogName = "SCA_CheckenFix_BitLocker"
#endregion#region Configuration
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12$LogDirectory = "C:\Log"
$LogFile = Join-Path $LogDirectory "$LogName $CurrentDate.log"
$TranscriptFile = Join-Path $LogDirectory "${CurrentDate}_${LogName}_Transcript.log"
$IntuneLogFolder = "C:\ProgramData\Microsoft\IntuneManagementExtension\Logs"$ExitCode = 1
#endregion#region Logging
function Write-Log {
param (
[string]$Level = "INFO",
[string]$Message
) $timestamp = (Get-Date).ToString("yyyy-MM-dd HH:mm:ss.fff")
Add-Content -Path $LogFile -Value "[$timestamp] [$Level] $Message"
}function Write-ConsoleAndLog {
param (
[string]$Message,
[string]$Level = "INFO"
) if (-not $Silent) {
Write-Output $Message
} Write-Log -Level $Level -Message $Message
}
#endregiontry { Write-ConsoleAndLog "Start controle op TPM en BitLocker." $OSDrive = $env:SystemDrive
$BitLockerVolume = Get-BitLockerVolume -MountPoint $OSDrive
$TPM = Get-Tpm if (-not $TPM.TpmPresent) {
throw "TPM is niet aanwezig."
} if (-not $TPM.TpmReady) {
throw "TPM is aanwezig maar niet gereed."
} $RecoveryProtectors = $BitLockerVolume.KeyProtector |
Where-Object { $_.KeyProtectorType -eq "RecoveryPassword" } if (-not $RecoveryProtectors) { Write-ConsoleAndLog "Recovery key ontbreekt. Toevoegen." Add-BitLockerKeyProtector `
-MountPoint $OSDrive `
-RecoveryPasswordProtector
} if ($BitLockerVolume.VolumeStatus -eq "FullyDecrypted") { Write-ConsoleAndLog "BitLocker inschakelen." Enable-BitLocker `
-MountPoint $OSDrive `
-EncryptionMethod XtsAes256 `
-UsedSpaceOnly `
-SkipHardwareTest
} $BitLockerVolume = Get-BitLockerVolume -MountPoint $OSDrive $RecoveryProtectors = $BitLockerVolume.KeyProtector |
Where-Object { $_.KeyProtectorType -eq "RecoveryPassword" } foreach ($Protector in $RecoveryProtectors) { BackupToAAD-BitLockerKeyProtector `
-MountPoint $OSDrive `
-KeyProtectorId $Protector.KeyProtectorId Write-ConsoleAndLog "Recovery key geback-upt naar Entra ID."
} Write-ConsoleAndLog "BitLocker configuratie voltooid."
$ExitCode = 0
}
catch { Write-ConsoleAndLog "Fout: $($_.Exception.Message)" "ERROR"
}
finally { exit $ExitCode
}

πŸš€ Samenvatting

Met dit script zorg je ervoor dat:

βœ… BitLocker automatisch wordt ingeschakeld
βœ… TPM wordt gecontroleerd
βœ… Recovery keys automatisch worden aangemaakt
βœ… Recovery keys veilig in Entra ID worden opgeslagen
βœ… Uitgebreide logging beschikbaar is

Een krachtige manier om endpoint-beveiliging automatisch af te dwingen binnen je organisatie.

About the Author

Vincent van Unen

Administrator

Visit Website View All Posts

Post navigation

Previous: Home Assistant Automation – Ochtendroutine met muziek β˜€οΈπŸŽΆ
Next: Powershell – πŸ”₯ Windows Firewall automatisch herstellen met Intune Proactive Remediation

Related Stories

ChatGPT Image Mar 11, 2026, 02_16_25 PM
  • Intune
  • Powershell

Powershell – πŸ”₯ Windows Firewall automatisch herstellen met Intune Proactive Remediation

Vincent van Unen 2026-03-11
ChatGPT Image Mar 11, 2026, 12_25_38 PM
  • Intune

Microsoft Intune πŸ“±

Vincent van Unen 2026-03-11
Powershell
  • Powershell

PowerShell – De plek waar luiheid en automatisering samenkomen ⚑

Vincent van Unen 2026-03-11

Recent Posts

  • Powershell – πŸ”₯ Windows Firewall automatisch herstellen met Intune Proactive Remediation
  • Powershell – πŸ” BitLocker automatisch controleren en inschakelen met PowerShell
  • Home Assistant Automation – Ochtendroutine met muziek β˜€οΈπŸŽΆ
  • Home Assistant – Automation Niemand thuis? Dan gaat alles automatisch uit 🏠
  • Home Assistant – Douche timer met kleurverloop πŸšΏπŸ”΄

Recent Comments

No comments to show.

You May Have Missed

ChatGPT Image Mar 11, 2026, 02_16_25 PM
  • Intune
  • Powershell

Powershell – πŸ”₯ Windows Firewall automatisch herstellen met Intune Proactive Remediation

Vincent van Unen 2026-03-11
ChatGPT Image Mar 11, 2026, 01_55_02 PM
  • Intune
  • Powershell

Powershell – πŸ” BitLocker automatisch controleren en inschakelen met PowerShell

Vincent van Unen 2026-03-11
ChatGPT Image Mar 11, 2026, 01_48_11 PM
  • Automations

Home Assistant Automation – Ochtendroutine met muziek β˜€οΈπŸŽΆ

Vincent van Unen 2026-03-11
ChatGPT Image Mar 11, 2026, 01_39_22 PM
  • Automations

Home Assistant – Automation Niemand thuis? Dan gaat alles automatisch uit 🏠

Vincent van Unen 2026-03-11
  • Algemeen
  • Fotografie
  • Home Assistant
  • Microsoft
  • Azure
  • Powershell
Copyright © 2026 All rights reserved. | ReviewNews by AF themes.