4 ms·
At least one subtle difference, is a bare scope block like TFA has, will print out everything in it instead of the output you would expect, where as Bash behave
by cyberbanjo 3y ago
At least one subtle difference, is a bare scope block like TFA has, will print out everything in it instead of the output you would expect, where as Bash behaves more like Invoke-Command -ScriptBlock {}.
Compare:
PS /home/me> {
>> $Env:MYSQL_HOST = "MyHost.com";
>> $Env:MYSQL_USER = "MyUser";
>> java -jar myprogram.jar;
>> }
$Env:MYSQL_HOST = "MyHost.com";
$Env:MYSQL_USER = "MyUser";
java -jar myprogram.jar;
PS /home/me> Invoke-Command -ScriptBlock {
>> $Env:MYSQL_HOST = "MyHost.com";
>> $Env:MYSQL_USER = "MyUser";
>> java -jar myprogram.jar;
>> }
Error: Unable to access jarfile myprogram.jar