Applying the answer to my previous question How to expand file content with powershell
I stumbled upon a fatal error when trying to expand this :
test.js:
<script type="text/javascript">
$('.mylink').click(function(event) {
var hash = $(this).attr("href");
});
// $var
</script>
test.ps1
$test = get-content -raw test.html
$var = "test"
# Write to output file using UTF-8 encoding *without a BOM*.
[IO.File]::WriteAllText(
"$PWD/out.html",
$ExecutionContext.InvokeCommand.ExpandString($test)
)