$RecoveryKey = (Get-BitLocker -MountPoint "C:").RecoveryKey $RecoveryKey | Out-File -FilePath "C:\RecoveryKey.txt"
Make sure you're running PowerShell with administrative privileges. Also, ensure that the BitLocker module is available and loaded; you can load it explicitly with: get bitlocker key powershell
For cloud-managed devices, you can use the Microsoft Graph PowerShell module to retrieve keys: powershell $RecoveryKey = (Get-BitLocker -MountPoint "C:")