我试图将值返回给我的批处理脚本。 在PowerShell中这个脚本工作正常:从cmd调用powershell命令时出错
PS> (Get-Date -Date "9.04.2017" -Uformat "%w.%Y-%m-%d").Replace("0.", "7.")
7.2017-04-09
,当我从一批尝试:
for /f %%a in ('powershell ^(Get-Date -Uformat "%%w.%%Y-%%m-%%d"^).Replace^(^'0.^', ^'7.^'^)') do set datestamp=%%a
echo %datestamp%
我得到的错误,但这个脚本工作正常:
for /f %%a in ('powershell ^(get-date^).DayOfWeek') do set weekday=%%a
for /f %%a in ('powershell Get-Date -Uformat "%%u.%weekday%.%%Y-%%m-%%d"') do set datestamp=%%a
echo %datestamp%
我在做什么错?
*“我有一个错误”*所以,它说什么? –
另外:我想不出为什么你会尝试从批处理中做到这一点的任何理由? – bluuf
我有一个很大的批处理脚本,我只需要一个powershell调用。也许以后我会把剧本改写成PowerShell。 – Antiokh