Bitlocker Recovery Key script does not work in Task Sequence

Pavel yannara Mirochnitchenko 11,716 Reputation points
2020-11-12T13:37:19.137+00:00

I am using MBAM and because of that I can't use build-in Enable Bitlocker Step. In TS, I first encrypt the drive with MBAM, and then idea is to just backup the recovery key to AD. Below script works manually but not in TS. Script exit code is also 0, but in TS it just doesn't do anything.

$volume = Get-BitLockerVolume -MountPoint "C:"
Backup-BitLockerKeyProtector -MountPoint "C:" -KeyProtectorId $volume.KeyProtector[1].KeyProtectorId

  • Manually, In Command Promt as admin works
  • Manually, with PSExec works
  • TS powershell as system doesn't do anything
  • TS powershell as admin doesn't do anything
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager Deployment
Microsoft Configuration Manager: An integrated solution for for managing large groups of personal computers and servers.Deployment: The process of delivering, assembling, and maintaining a particular version of a software system at a site.
902 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Gary Blok 1,736 Reputation points
    2020-11-12T21:43:03.657+00:00

    Can you try this instead?

    $keyprotector = (((Get-BitLockerVolume -MountPoint "C:").KeyProtector) | Where-Object {$_.KeyProtectorType -eq "RecoveryPassword"}).KeyProtectorId
    Backup-BitLockerKeyProtector -MountPoint "C:" -KeyProtectorId $keyprotector
    

    Also, where is the step that you're running this? Near the end of the TS?
    If you run the TS Debugger, after you've run your Script to Enable Bitlocker, and it adds the protectors, can you pause the TS, launch the Command Prompt, confirm the Protector is there, then launch PowerShell and test your script.

    When I tested your script, it didn't work for me, since [1] was the TPM keyprotector and not the Recovery Password.

    1 person found this answer helpful.
    0 comments No comments

  2. Pavel yannara Mirochnitchenko 11,716 Reputation points
    2020-11-13T08:18:26.367+00:00

    Thanks for the input, I tested your script but still the same problem. First, from Invoke-PS1 script I see this, but it is probably okay, because after 30 seconds, it does succeed, right?

    39626-image.png

    But then, your script errors like that (but the step does complete with exit 0). Unfortunatelly, before this testing, I didn't read the smsts.log, only status message view with didn't reveal any errors.

    39529-image.png


  3. Pavel yannara Mirochnitchenko 11,716 Reputation points
    2020-11-13T10:19:22.87+00:00

    I just want to confirm, that using Enable Bitlocker built-in step in my enviroment does take the key to AD, so my enviroment is okay for that :)