Skip to main content

Pobieranie klucza BitLocker z AD

Należy uruchomić powershell jako user z uprawnieniami do odczytu atrybutów

$objComputer = Get-ADComputer NAZWAKOMPUTERA
$Bitlocker_Objects = Get-ADObject -Filter {objectclass -eq 'msFVE-RecoveryInformation'} -SearchBase $objComputer.DistinguishedName -Properties 'msFVE-RecoveryPassword'
$Bitlocker_Objects

Wynik:

image.png

Bardziej skomplikowana wersja - z pytaniem o nazwę komputera oraz poświadczenia domenowe:

# Pobieranie nazwy komputera
$ComputerName = Read-Host "Nazwa komputera [$env:COMPUTERNAME]"
if ([string]::IsNullOrWhiteSpace($ComputerName)) {
    $ComputerName = $env:COMPUTERNAME
}

# Pobieranie poświadczeń domenowych
$Credentials = Get-Credential -Message "Poświadczenia do domeny AD"

# Wyszukanie odpowiedniego komputera
$objComputer = Get-ADComputer $ComputerName -Credential $Credentials

# Pobranie kluczy BitLocker z dodatkowymi polami
$Bitlocker_Object = Get-ADObject `
    -Filter {objectclass -eq 'msFVE-RecoveryInformation'} `
    -SearchBase $objComputer.DistinguishedName `
    -Properties 'msFVE-RecoveryPassword','msFVE-RecoveryGuid','msFVE-VolumeGuid','whenCreated' `
    -Credential $Credentials |
    Sort-Object whenCreated -Descending |
    Select-Object `
        @{Name='CN'; Expression={ $ComputerName }},
        @{Name='Bitlocker Password'; Expression={ $_.'msFVE-RecoveryPassword' }},
        @{Name='Volume GUID'; Expression={ $_.'msFVE-VolumeGuid' }},
        @{Name='Recovery GUID'; Expression={ $_.'msFVE-RecoveryGuid' }},
        @{Name='Created'; Expression={ $_.whenCreated }}

# Wypisanie danych
$Bitlocker_Object | Format-Table -AutoSize

Wynik: 

image.png