Calling dynamic variable in PowerShell

First of all, your New-Variable invocation doesn’t do what you think it does, as you’d pipe the output of New-Variable to Where-Object instead of using the value of $Transactions | Where … as value for the variable. You need parentheses for that to work: New-Variable -Name “Transactions_$Year” -Value ($Transactions | Where {$_.Date -like “*.$Year” }) … Read more