# Install-Module -Name Microsoft.
Graph -Scope CurrentUser -Force
Import-Module [Link]
Import-Module [Link]
# Connect to Microsoft Graph interactively (device administrator role
required)
Connect-MgGraph -Scopes "[Link]","[Link]"
# Ask for device names (machine NAME, case-insensitive, unique within
tenant)
$deviceInput = Read-Host "Enter device names (comma, space, or line
separated)"
$deviceNames = $deviceInput -split "[,`n`r\s]+" | ForEach-Object
{ $_.Trim() } | Where-Object { $_ }
foreach ($device in $deviceNames) {
# Find device object in Azure Entra ID
$deviceObject = Get-MgDevice -Filter "displayName eq '$device'" -
Property Id,DisplayName
if ($deviceObject) {
foreach ($dev in $deviceObject) {
Write-Host "Device Found: $($[Link]) ($($[Link]))" -
ForegroundColor Cyan
$keys = Get-MgInformationProtectionBitlockerRecoveryKey -DeviceId
$[Link]
if ($keys) {
foreach ($key in $keys) {
Write-Host "Recovery Key for Device $($[Link]): $
($[Link])" -ForegroundColor Green
} else {
Write-Host "No BitLocker recovery keys found for $
($[Link])." -ForegroundColor Yellow
} else {
Write-Host "Device '$device' not found in Azure Entra ID." -
ForegroundColor Red