Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Running SFTP from script but Task Scheduler does not like part of it.

$
0
0

Hello,

I am trying to do some (not so) simple file copying using SFTP in this manner:

 1) Map a drive to the destination, the SFTP program will not accept UNC paths
 2) Use SFTP to copy the files to the target Server
 3) Write a Timestamped entry to a log file
 4) Remove the source files after copy
 5) Remove the drive mapping

Everything works but Step two and that only fails running from the Task Scheduler (W2K8 R2).  Running from the command line directly in PowerShell or using the Run box works fine all the way.

The sftp program is BitVise SSH Client using their log utility.  The makes the command line very complicated.

The line I use in the Scheduler is powershell "D:\Scripts\SFTP_TPCCommission.ps1" Dev  I have also tried using the -command parameter.  Again, it only does not work in the scheduler.

Here is how I invoke it:

$CmdLine = "`"D:\\Program Files (x86)\\Bitvise SSH Client\\logs\\`" sftpc " + $Server + " -pk=1 -cmd=`"put -o -lf Z:\" + $File + " /TPCCommissions`""
& log ($CmdLine)

I have also tried a Here String to do the same thing.  It works the same way.

$ArgText = @"
"D:\\Program Files (x86)\\Bitvise SSH Client\\logs\\" sftpc $Server -pk=1 -cmd="put -o -lf Z:\$File /TPCCommissions"
"@

Any ideas?


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>