When using WinRM-based remoting, the -ScriptBlock argument can be passed positionally; e.g.:
Invoke-Command -ComputerName . { 'hi' }
# Implied: Invoke-Command -ComputerName . -ScriptBlock { 'hi' }
Currently, this doesn't work for the equivalent SSH-based remoting commands:
Steps to reproduce
This assumes that the local machine is set up for SSH-based remoting.
{ Invoke-Command -HostName . { 'hi' } } | Should -Not -Throw
{ Invoke-Command -SSHConnection @{ HostName = '.' } { 'hi' } } | Should -Not -Throw
Expected behavior
Both tests should pass.
Actual behavior
Both tests fail as follows:
Expected no exception to be thrown, but an exception
"A positional parameter cannot be found that accepts argument ' 'hi' '." was thrown from line:1 char:3
That is, positional use of the -ScriptBlock parameter is not supported.
Environment data
PowerShell Core 7.0.0-preview.4
When using WinRM-based remoting, the
-ScriptBlockargument can be passed positionally; e.g.:Currently, this doesn't work for the equivalent SSH-based remoting commands:
Steps to reproduce
This assumes that the local machine is set up for SSH-based remoting.
{ Invoke-Command -HostName . { 'hi' } } | Should -Not -Throw { Invoke-Command -SSHConnection @{ HostName = '.' } { 'hi' } } | Should -Not -ThrowExpected behavior
Both tests should pass.
Actual behavior
Both tests fail as follows:
That is, positional use of the
-ScriptBlockparameter is not supported.Environment data