Select Page

Required Files: None


Get Bitlocker Recovery Key(s) and store them in a custom field called “Bitlocker_Keys”


 

#TODO - MAKE SURE YOU SETUP YOUR ASSET CUSTOM FIELD CALLED "Bitlocker_Key_<drive>" for each drive as a "Text Field" on your 
# Syncro Device asset type. Assets -> Manage Types -> Syncro Device -> New Field
# Based on the Syncro Staff product keys script.
 
Import-Module $env:SyncroModule
 
#Creates temp directory if it does not exist
Set-Location C:\
md temp
Set-Location C:\Temp
 
#Puts keys into text files
(Get-BitLockerVolume -MountPoint C).KeyProtector.recoverypassword > C:\Temp\bitlockerkeyc.txt
(Get-BitLockerVolume -MountPoint D).KeyProtector.recoverypassword > C:\Temp\bitlockerkeyd.txt
(Get-BitLockerVolume -MountPoint E).KeyProtector.recoverypassword > C:\Temp\bitlockerkeye.txt
 
Start-Sleep -Seconds 15
 
#Gets keys from text files
[string] $textc = Get-Content C:\Temp\bitlockerkeyc.txt -raw
[string] $textd = Get-Content C:\Temp\bitlockerkeyd.txt -raw
[string] $texte = Get-Content C:\Temp\bitlockerkeye.txt -raw
 
#Adds keys to Syncro
Set-Asset-Field -Subdomain "xxxx" -Name "Bitlocker_Key_C" -Value $textc
write-host "Set the custom field value to $textc"
 
Set-Asset-Field -Subdomain "xxxx" -Name "Bitlocker_Key_D" -Value $textd
write-host "Set the custom field value to $textd"
 
Set-Asset-Field -Subdomain "xxxx" -Name "Bitlocker_Key_E" -Value $texte
write-host "Set the custom field value to $texte"
 
#Removes text files with keys from PC for security
Set-Location C:\Temp
Del bitlockerkeyc.txt
Del bitlockerkeyd.txt
Del bitlockerkeye.txt