When invoke-epstemplate is called from within a function, it only sees variables defined outside the function unless they are specifically added with the Binding hashtable.
eps.txt:
PowerShell script
Import-Module EPS
$value = "Outside"
Function FunctionTest
{
$value = "Inside"
Write-Host "From a function, the value of `$value is $value"
Write-Host "From a function, the result from invoke is $(Invoke-EpsTemplate -Path "eps.txt")"
Write-Host "From a function, the result from invoke WITH BINDING is $(Invoke-EpsTemplate -Path "eps.txt" -Binding @{"value"=$value})"
}
Write-Host "The value of `$value is $value"
Write-Host "The value from invoke is $(Invoke-EpsTemplate -Path "eps.txt")"
FunctionTest
Results:
> The value of $value is Outside
> The value from invoke is Outside
> From a function, the value of $value is Inside
> From a function, the value from invoke is Outside
> From a function, the value from invoke WITH BINDING is Inside
Expected results:
> The value of $value is Outside
> The value from invoke is Outside
> From a function, the value of $value is Inside
> From a function, the value from invoke is Inside
> From a function, the value from invoke WITH BINDING is Inside
When invoke-epstemplate is called from within a function, it only sees variables defined outside the function unless they are specifically added with the Binding hashtable.
eps.txt:
PowerShell script
Results:
Expected results: