$computers = Get-Content -Path "C:\ComputerList.txt" foreach ($pc in $computers) if (Test-Connection -ComputerName $pc -Count 1 -Quiet) try $key = Invoke-Command -ComputerName $pc -ScriptBlock (Get-BitLockerVolume -MountPoint "C:").KeyProtector -ErrorAction Stop [PSCustomObject]@Computer=$pc; RecoveryKey=$key; Status="Success"
This works even if the PC is dead or offline. Use this method when possible. Don't wait for a boot-loop emergency to figure this out. Test Method 1 on a lab machine today. Better yet, script Method 3 into a weekly audit report so you always know where your recovery keys are. powershell get bitlocker recovery key remote computer
Invoke-Command -ComputerName "PC-WS001" -ScriptBlock Select-Object -ExpandProperty RecoveryPassword $computers = Get-Content -Path "C:\ComputerList
Do you pull keys from AD, Entra ID, or directly from the remote client? Drop your favorite one-liner in the comments below. Keep scripting, and stay secure. Test Method 1 on a lab machine today
else [PSCustomObject]@Computer=$pc; RecoveryKey=$null; Status="Offline"
catch [PSCustomObject]@Computer=$pc; RecoveryKey=$null; Status="Failed: $ "