Try:
$file = "C:\Source\asdf.csv" $user = "user" $pass = "pass" $hst = "host" $path="C:\ProgramFiles\psftp.exe" $cmd = @( "cd ..", "cd upload", "put $file", "bye" ) $cmd | & $path -pw $pass " $user@ $hst"
In response to questions in the comment:
The first part, "$ cmd |" prints the contents of $ cmd to the following command. Since this is an external program (unlike a cmdlet or function), it will send the contents of $ cmd to the stdin of the external program.
The & $ path part says that it treats the contents of $ path as the name of a command or program and executes it.
The rest of the line is passed to the external program as command line arguments.
source share