3

i am refering to this question ASSIGN win XP commandline output to variable

i am trying to use it on a powershell code segment so i typed

powershell date (get-date).AddDays(-1) -format yyyyMMdd

and confirm it returns like

20100601

but then if i tried to

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

then it failed to work as expected. how can i transfer the date to a variable?

1 Answer 1

5

Maybe

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

is what you wanted.

Sign up to request clarification or add additional context in comments.

1 Comment

exactly! i hope i knew the way to quote it inside there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.