I've been trying to use the following code to quickly display a computer's serial number through command prompt. Trying to use the powershell command because Microsoft will be getting rid of WMIC.
FOR /F "usebackq delims=" %%A IN ('powershell.exe -NoProfile -Command "Get-CimInstance Win32_BIOS | Select-Object -ExpandProperty SerialNumber"') DO (SET "serial=%%A")
ECHO %serial%
When run from the batch file the serial number that gets displayed to the screen is:
powershell.exe -NoProfile -Command "Get-CimInstance Win32_BIOS | Select-Object -ExpandProperty SerialNumber"
How can I make this work?