SYNOPSIS
Invokes the backup of BitLocker recovery keys to Intune for all Intune managed devices.SYNTAX
Default (Default)
KeyVault
DESCRIPTION
This script connects to Microsoft Intune and retrieves BitLocker recovery keys from all devices managed by Intune. It requires the Microsoft Graph PowerShell SDK to be installed and appropriate permissions to access device management and BitLocker key data.EXAMPLES
EXAMPLE 1
EXAMPLE 2
EXAMPLE 3
EXAMPLE 4
EXAMPLE 5
EXAMPLE 6
EXAMPLE 7
PARAMETERS
-IncludeDeviceInfo
Switch to include device information such as device name, OS, compliance status, etc.-IncludeDeviceOwner
Switch to include device owner information (UPN). Requires IncludeDeviceInfo parameter.-ExportToExcel
Switch to export the results to an Excel file in the user profile directory. If not specified, the function returns the data objects.-ShowKeyInPlainText
Switch to display BitLocker recovery keys in plain text format in the output. WARNING: This will expose sensitive BitLocker recovery keys! Only use when absolutely necessary and ensure secure handling of the output. Without this parameter, keys will be hidden for security (displayed as ‘[HIDDEN]’).-RunFromAzureAutomation
(Optional) If specified, uses managed identity authentication instead of interactive authentication. This is useful when running the script in Azure environments like Azure Functions, Logic Apps, or VMs with managed identity enabled. PowerShell modules used in Azure Automation must be a MAXIMUM of version 2.25.0 when using PowerShell < 7.4.0, because starting from version 2.26.0, PowerShell 7.4.0 is required, and Azure Automation does not support it yet as of February 2026. For PowerShell 7.4.0+, there are no version restrictions. https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3147 https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3151 https://github.com/microsoftgraph/msgraph-sdk-powershell/issues/3166-BackupToKeyVault
Switch to enable backup of BitLocker recovery keys to Azure Key Vault. Must be used together with -KeyVaultName.-KeyVaultName
Specify the name of Azure Key Vault to backup BitLocker recovery keys. Mandatory when -BackupToKeyVault is specified. Requires Azure PowerShell module and appropriate permissions to access Key Vault. Keys will be stored with device name and BitLocker key ID as the secret name.-DeviceName
Filter results to a specific device by its display name. Cannot be used together with DeviceID parameter.-DeviceID
Filter results to a specific device by its device ID (GUID). Cannot be used together with DeviceName parameter.CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.INPUTS
OUTPUTS
NOTES
Author: Bastien Perez (adapted from Vasil Michev) Source: https://github.com/michevnew/PowerShell/blob/master/GraphSDK_Bitlocker_report.ps1 The script requires the following Microsoft Graph permissions:- BitLockerKey.Read.All (required) - Allows the app to read BitLocker keys on behalf of the signed-in user, for their owned devices. Allows read of the recovery key.
- Device.Read.All (optional) - Needed to retrieve device details like name, OS, compliance status
- User.ReadBasic.All (optional) - Needed to retrieve device owner UPN information
- User context: Can only read BitLocker keys for devices owned by the signed-in user (if you have admin permissions, you can read all devices and all bitlocker keys)
- Application context: Can read BitLocker keys for all devices in the organization (requires admin consent)
- Managed Identity: Same as application context when properly configured with admin consent