[英]Store powershell output in a variable in CMD
In a batchfile, how do I store the output of a powershell command in a variable This isn't working 在批处理文件中,如何将powershell命令的输出存储在变量中
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
给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"
给出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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.