0
##$parseDateTaken is not defined yet but will be before $DateDir is set.
##It's being used as a toggle to include or exclude the year directory.

$YearDir = "\" + {(Get-Date $parseDateTaken).Year}
...
$DateDir = $YearDir + "\" + $parseDateTaken

How can get the block of code to run when $YearDir is used? Right now it only interprets the whole thing as a string. I want to keep it a oneliner.

2
  • 1
    I would use $ExecutionContext.InvokeCommand.ExpandString for this. Commented Jul 25, 2019 at 17:35
  • 2
    $YearDir = { "\" + ((Get-Date $parseDateTaken).Year) }; $DateDir = (& $YearDir) + "\" + $parseDateTaken Commented Jul 25, 2019 at 19:04

0

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.