I'm trying to return value to my batch script. In powershell this script works fine:
PS> (Get-Date -Date "9.04.2017" -Uformat "%w.%Y-%m-%d").Replace("0.", "7.")
7.2017-04-09
When i try from batch:
for /f %%a in ('powershell ^(Get-Date -Uformat "%%w.%%Y-%%m-%%d"^).Replace^(^'0.^', ^'7.^'^)') do set datestamp=%%a
echo %datestamp%
I get errors, but this script works fine:
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%
What am I doing wrong?