I have a script for bitlocker encryption that encrypts system drive. now my management wants to include all other data drives.
Now, I'm having a hard time creating a for loop because drives is not displaying. so assigned variables are not able to run properly on commands a throw.
I wanted to do a for loop to check all data drives except external drives and usb using
wmic logicaldisk where "drivetype=3" get deviceid /format:list
but I'm quite having a hard time. I have put my modified script that is not working yet below.
If you think what I have is a spaghetti code, please help me modify. maybe you have other efficient way.
@echo off
setlocal enabledelayedexpansion
for /F "skip=1 tokens=2 delims=:" %%L in ('wmic logicaldisk where "drivetype=3" get deviceid /format:list') do (
echo Checking drive: %%L
for /F "tokens=3 delims= " %%A in ('manage-bde -status %%L ^| findstr " Encryption Method:"') do (
if "%%A"=="AES" goto EncryptionCompleted
)
for /F "tokens=3 delims= " %%A in ('manage-bde -status %%L ^| findstr " Encryption Method:"') do (
if "%%A"=="XTS-AES" goto EncryptionCompleted
)
for /F "tokens=3 delims= " %%A in ('manage-bde -status %%L ^| findstr " Encryption Method:"') do (
if "%%A"=="None" goto TPMActivate
)
goto ElevateAccess
)