What I am trying to do is in your reference link. []
I use start-demo function mentioned in that blog post to automate demo. Start-demo reads one-liners from text file and invoke them line by line. As written in the post, it invokes command line like following,
Invoke-Expression $(".{" + $_lines[$_i] + "}| out-host")
$_lines holds one-liners read from text file.
When I added 'get-date|out-gauge -refresh 0:0:1' to my demo commands for example, out-gauge shows error I wrote earlier. Out-gauge was invoked as
.{ get-date | out-gauge -refresh 0:0:1 } | out-host
While following invokes out-gauge -refresh without error.
Invoke-Expression $(".{`n" + $_lines[$_i] + "}| out-host")
Actual lines would be
{
get-date | out-gauge -refresh 0:0:1 } | out-host