In a batchfile, how do I store the output of a powershell command in a variable This isn't working
set yest=powershell get-date((get-date).addDays(-1)) -uformat "%Y%m%d"
powershell get-date((get-date).addDays(-1)) -uformat "%Y%m%d"
gives 20130623
set yest=powershell get-date((get-date).addDays(-1)) -uformat "%Y%m%d"
echo %yest%
gives powershell get-date((get-date).addDays(-1)) -uformat "md"
The closing braces and percent need to be escaped/doubled.
@echo off
for /f "delims=" %%a in ('powershell get-date((get-date^).addDays(-1^)^) -uformat "%%Y%%m%%d"') do set d8=%%a
echo %d8%
pause
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With