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.

Fr3nZy
  • 65
  • 1
  • 6
  • 1
    I would use [`$ExecutionContext.InvokeCommand.ExpandString`](https://stackoverflow.com/a/56627626/1701026) for this. – iRon Jul 25 '19 at 17:35
  • 2
    `$YearDir = { "\" + ((Get-Date $parseDateTaken).Year) }; $DateDir = (& $YearDir) + "\" + $parseDateTaken` – user4003407 Jul 25 '19 at 19:04

0 Answers0