Hello,
I have a PowerShell script. I am using SFTP.
$sessionOptions = New-Object WinSCP.SessionOptions -Property @{
Protocol = [WinSCP.Protocol]::Sftp
HostName = $hostname
UserName = $config.Configuration.UserName
SecurePassword = ConvertTo-SecureString $config.Configuration.Password
}
The
default shell in the target host is
ksh
. I want to execute a command:
$Command = "ls -ltr"
$output = $session.ExecuteCommand($Command)
I get this error:
Your shell is probably incompatible with the application (BASH is recommended)
If I execute this command against a host where the default shell is
/bin/bash
,
it works.
Question is: How can I direct SFTP to use
ksh
as the shell for the command execution?
Note:
I cannot change the default host from
ksh
to
bash
because it is a company policy and I have hundreds of hosts.
-rawsettings
option
shell
, the documentation states is only for SCP protocol
https://winscp.net/eng/docs/rawsettings
Shell (SCP protocol)
In this post (
Connection has been unexpectedly closed. Server sent command), someone suggested he/she can change the shell:
Oh, you know, looking through the options I changed the shell to /bin/ksh
and it worked.
but does not explain how.
Regards, Raul.