I've been trying to create an easier way for my team to get the bitlocker status of devices on our network. After checking through a bunch of seperate answers on here and other sites I've managed to cobble together an almost working batch script, however it doesn't seem to be pulling the entry correctly. Code is below:
@echo off
color a
title BitLocker Checking
:start
cls
setlocal EnableDelayedExpansion
set i=0
for /F %%a in ('net view') do (
set line=%%a
if "!line:~0,2!" equ "\\" (
set /A i+=1
echo [!i!] !line:~2!
set comp[!i!]=!line:~2!
)
)
echo.
echo.
echo Choose a computer.
choice /c 12345678 >nul
set name=!comp[%errorlevel%]!
cls
for /f "tokens=1,2 delims=[]" %%A in ('manage-bde -status -computername %name% ^| find "Conversion Status"') do set derp=%%B
if "%name%"=="" goto start
echo The status of %name% is %derp%
echo.
echo.
echo %derp% | clip
echo. %derp% copyied to clipboard.
echo.
echo Press any key.
pause
goto start
When I take the manage-bde -status -computername %name% | find "Conversion Status"
line in isolation and provide it with a computername, it seems to pull the conversion status line correctly (e.g. "Conversion Status : Fully Decrypted" if bitlocker is off on the machine).
However if left in context of the batch file, it outputs "The status of computernamegoeshere is" and then a blank, as if it's not getting the data from the Find command into the variable %B.
Anyone have any suggestions? It's been a while since I've written batch commands so a bit rusty.