I run this command script:
$hm = "$Env:USERPROFILE"
$eclipse_path = "$hm\eclipse\committers-2019-09\eclipse\eclipse.exe"
$sp = {
"$eclipse_path -data C:\SharedData\Projects\Tutorial &"
Write-Host "Eclipse starting"
}
Invoke-Command -ScriptBlock $sp
with the following results:
>>> bin/dev.ps1 C:\Users\jgoss\eclipse\committers-2019-09\eclipse\eclipse.exe -data C:\SharedData\Projects\Tutorial &
Eclipse starting >>>
It appears that the main command was not executed but the echo command was executed. If I run the main command standalone in Windows Terminal as shown, the command works as desired:
>>> C:\Users\jgoss\eclipse\committers-2019-09\eclipse\eclipse.exe -data C:\SharedData\Projects\Tutorial &
I simply cut and paste the contents of the first command in the script block and it worked as I want. The program eclipse.exe was started in the background. Why does this not work within a script block?