Hi,
Been struggling with this for the past week, and couldn't find much online, so thought Id share my Pre-Installation task BAT script I have recently created so that we can use the same Scripted Installation whether we boot from UEFI or legacy BIOS means.
Basically it queries a registry key in WinPE to determine whether the boot was UEFI or Legacy and then runs one of 2 diskpart scripts depending on the outcome. I also wanted it self contained so the diskpart scripts are written on the fly rather than kept as dependencies

REG QUERY “HKLM\System\CurrentControlSet\Control” /v “PEFirmwareType” | Find “2”

IF %ERRORLEVEL% == 0 goto UEFI
IF %ERRORLEVEL% == 1 goto BIOS

goto END

:UEFI
(
ECHO select disk 0
ECHO clean
ECHO convert basic noerr
ECHO convert gpt noerr
ECHO create partition efi size=200
ECHO assign letter=s
ECHO format quick fs=FAT32
ECHO create partition msr size=128
ECHO create partition primary
ECHO assign letter=c
ECHO format quick fs=NTFS
ECHO exit
)>X:\Windows\System32\UEFI.txt
diskpart /s X:\Windows\System32\UEFI.txt
goto END

:BIOS
(
ECHO select disk 0
ECHO clean
ECHO convert basic noerr
ECHO convert mbr noerr
ECHO create partition primary size=500
ECHO select partition 1
ECHO active
ECHO assign letter=s
ECHO format quick fs=NTFS
ECHO create partition primary
ECHO select partition 2
ECHO assign letter=c
ECHO format quick fs=NTFS
ECHO exit
)>X:\Windows\System32\BIOS.txt
diskpart /s X:\Windows\System32\BIOS.txt
bootsect.exe /NT60 c:
goto END

:END


Obviously the diskpart commands can be changed to suit whatever your needs. Hopefully will help someone!

Obviously provided as is with no support.