I hope you and your family are doing well- I've been struggling with this error that I really don't understand.
This is the PowerShell script that I created to upload files to a ftp server using PSFTP
$path="C:\Users\jhosef.cardich\Desktop\sol\psftp.exe"
$comd1= "lcd C:\Users\jhosef.cardich\Desktop\sol\"
$upload_result = ($comd1) | & $path -pw $pass "$user@$hst" 2> $
$comd2="put myfile,txt"
$upload_result+= $comd2 | & $path -pw $pass "$user@$hst" 2> $
$upload_result | Out-File -FilePath "C:\Users\jhosef.cardich\Desktop\sol\sftp.txt" -Append
"DateTime Stamp - Upload: $(Get-Date)" | Out-File -FilePath "C:\Users\jhosef.cardich\Desktop\sol\sftp.txt" -Append
and this the output I get every time I run my code: (I would like you to focus on the second line)
Remote working directory is /download
psftp> psftp: unknown command "ktop\sol\"
psftp> quit
Remote working directory is /download
psftp> quit
DateTime Stamp - Upload: 11/18/2020 21:21:49
As you can see, I do not understand why in the second line I get the error "unknown command" and it seems that psftp only detects a part of the string where I have defined the path. I also tried this implementation but I'm getting the same error (Call multiple commands from powershell e.g psftp).