批处理文件将命令返回的值分配给变量(来自powershell)

nok*_*eat 3 powershell batch-file

我正在引用这个问题 ASSIGN win XP命令行输出到变量

我试图在powershell代码段上使用它,所以我输入

powershell date (get-date).AddDays(-1) -format yyyyMMdd
Run Code Online (Sandbox Code Playgroud)

并确认它返回如

20100601
Run Code Online (Sandbox Code Playgroud)

但是如果我试着的话

for /f "tokens=*" %a in ('powershell date get-date -format yyyyMMdd
') do set var=%a
Run Code Online (Sandbox Code Playgroud)

然后它没能按预期工作.如何将日期转移到变量?

ste*_*tej 5

也许

for /f "tokens=*" %a in ('powershell "get-date; get-date -format yyyyMMdd"') do set var=%a
Run Code Online (Sandbox Code Playgroud)

是你想要的.