Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Powershell - using WINSCP to submit files to Filetype = JES

Status
Not open for further replies.

DBDivaAuto

IS-IT--Management
May 9, 2017
29
US
Hi Everyone,

I am trying to automate a process that I think should be possible in Powershell using the WINSCP as a mediator.

The line in question is
Code:
"call `"`"site filetype=JES`"`"" `
which I also tried
Code:
"call site filetype=JES" `

Code:
# PowerShell >=7.3

$PSNativeCommandArgumentPassing = "Legacy"

& "C:\Program Files (x86)\WinSCP\WinSCP.com" `
  /log="C:\IPM\FTPLogs\WinSCP.log" /ini=nul `
  /Command  "open ftps://USERNAME:PW@SOMESITE.hhsc.texas.gov/" `
    "lcd c:\CareUpload\" `
   [b] "call `"`"site filetype=JES`"`"" `[/b]
    "mput -nopreservetime -nopermissions  CB%TIMESTAMP#yymmdd%" `
    "exit"

$winscpResult = $LastExitCode
if ($winscpResult -eq 0)
{
  Write-Host "Success"
}
else
{
  Write-Host "Error"
}

The code runs and returns the following:

PS C:\Windows\system32> C:\Scripts\PutCareBatch.ps1
Connecting to SOMESITE.hhsc.texas.gov:990 ...
TLS connection established. Waiting for welcome message...
Connected
Starting the session...
Session started.
Active session: [1] LOGIN@SOMESITE.hhsc.texas.gov
c:\CareUpload
200 SITE command was accepted
CB230331 | 84 KB | 270.5 KB/s | binary | 100%
Success

The session is starting, the login is accepted, I am passing the site command and the file name and size is there correctly but it is not landing in the Site Filetype = JES area.

Does anyone have code for something similar?
 
IMO it should be
Code:
"call site filetype=JES" `
 
Mikrom - one would think. The code runs and gives the verification that the SITE command was accepted but the file is not making it up to the remote server. I am wondering if it's a time issue. Like the time between the verification and the transfer of the file needs a little break in between.
 
and are you sure that this mput works ?:
Code:
"mput -nopreservetime -nopermissions  CB%TIMESTAMP#yymmdd%" `
Have you tried instead only simple put like this if it works or not ?:
Code:
"put only_one_file" `
 
I will try that this afternoon. Another restraint here is that I can only test in a little window everyday because you get 1 batch upload per day. I will let you know if it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top