Backup Bitlocker key to Active Directory

If for some reason the Bitlocker key of your hard drive is missing in Active Directory, then you can execute the following commands to still backup the Bitlocker key.

# Select the drive that is encrypted with bitlocker
$drive = Get-BitLockerVolume | Where-Object {
    $_.KeyProtector | Where-Object {
        $_.KeyProtectorType -eq 'RecoveryPassword'
    }
} | Select-Object -f 1 

# Get the bitlocker key from the selected drive
$key = $drive | Select-Object -exp KeyProtector | Where-Object {
    $_.KeyProtectorType -eq 'RecoveryPassword'
} | Select-Object -f 1

# Write the bitlocker key to the Active Directory Backup-BitLockerKeyProtector
$drive.MountPoint
$key.KeyProtectorId

# Show message on screen when running manually
Write-Host "Backing up drive $drive, key $($key.KeyProtectorId), password $($key.RecoveryPassword)"