I guess I have it 90% correct, but a small part seems to be missing...
I have no problem opening a remote session from Windows -> Linux (host) No problem passing a command either. This works fine:
$Session = New-PSSession -SSHTransport -HostName 192.168.0.10 -UserName user
Invoke-Command -Session $Session { bash ~/sh/test.sh }
But when I try to turn my command into a variable:
$cmd = "bash ~/sh/test.sh"
Invoke-Command -Session $Session { & "$using:cmd" }
I get the following error message:
The term 'bash ~/sh/test.sh' is not recognized as the name of a cmdlet, function, script file, or operable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
+ CategoryInfo : ObjectNotFound: (bash ~/sh/test.sh:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
+ PSComputerName : 192.168.0.10
I have tested the path issue as part of the error message. Any ideas ?
Thanks, Philippe