"Requested action not taken" Message when Uploading Files

Advertisement

rsford31
Joined:
Posts:
32

"Requested action not taken" Message when Uploading Files

Hi,
I have a script that first checks if there are files in the local source folder. If there is, it establishes a connection to the FTP server and reads in a CSV file with two columns: file and dest.
It loops through the files in the local source file with an inner loop looping through the CSV file. If the file at source matches the file in the CSV file, the file is to be uploaded to the full path to the directory in the corresponding DEST column. Files need to be uploaded to specific directories depending on the file name pattern.

if ($file.name -like $row.FILENAME){
  $filename = $file.fullname
  $dest = $row.DEST
  Write-Host "Transferring $($file.name) to $($row.DEST)."
  $transferResult = $session.PutFiles($filename, $dest, $true)
                 
  if (!$transferResult.IsSuccess){
    Write-Host (
      "Error uploading file $($fileInfo.FullName): " + "$($transferResult.Failures[0].Message)")
    $flag++
  }else{
    Write-Host "File $($file.name) uploaded successfully!"
    $emailbody.Add($file.name)
  }
}
It's failing for each file though with
Copying files to remote side failed.
Requested action not taken. The file could not be opened or created."
– The files are a mix of 0 kb and 1 kb and all are failing with the same message.
– I'm able to manually upload the files from the local source folder (the same one used in the code) to the destination folder so it's not permissions.
– I've confirmed the path to the files are correct.
– I've confirmed the destination paths are correct. I even copied the path by copying the path to the clipboard from WinSCP
– I've hard coded the variables with the full path to the file and the file name and the destination.

Here are the logs for the first file upload attempt:
. 2021-04-21 16:10:51.095 --------------------------------------------------------------------------
. 2021-04-21 16:10:51.095 WinSCP Version 5.15.9 (Build 10071) (OS 10.0.14393 - Windows Server 2016 Standard)
. 2021-04-21 16:10:51.095 Configuration: nul
. 2021-04-21 16:10:51.095 Log level: Normal
. 2021-04-21 16:10:51.095 Local account: ACTIVEDOMAIN\****
. 2021-04-21 16:10:51.095 Working directory: E:\Program Files\WinSCP
. 2021-04-21 16:10:51.095 Process ID: 16272
. 2021-04-21 16:10:51.095 Command-line: "E:\Program Files\WinSCP\winscp.exe" /xmllog="C:\Users\****\AppData\Local\Temp\wscp3CC8.01EF1D98.tmp" /xmlgroups /xmllogrequired /nointeractiveinput /dotnet=5.15.9  /ini=nul /log="F:\WinscpLogs\Test_SessionLog.txt"  /console /consoleinstance=_15560_37590783_154
. 2021-04-21 16:10:51.095 Time zone: Current: GMT-5, Standard: GMT-6 (Central Standard Time), DST: GMT-5 (Central Daylight Time), DST Start: 3/14/2021, DST End: 11/7/2021
. 2021-04-21 16:10:51.095 Login time: Wednesday, April 21, 2021 4:10:51 PM
. 2021-04-21 16:10:51.095 --------------------------------------------------------------------------
. 2021-04-21 16:10:51.095 Script: Retrospectively logging previous script records:
> 2021-04-21 16:10:51.095 Script: option batch on
< 2021-04-21 16:10:51.095 Script: batch           on        
< 2021-04-21 16:10:51.095 Script: reconnecttime   120       
> 2021-04-21 16:10:51.095 Script: option confirm off
< 2021-04-21 16:10:51.095 Script: confirm         off       
> 2021-04-21 16:10:51.095 Script: option reconnecttime 120
< 2021-04-21 16:10:51.095 Script: reconnecttime   120       
> 2021-04-21 16:10:51.095 Script: open ftp://****:***@****-implicit -certificate="ca:34:2d:f0:7a:4b:56:5a:ee:d2:25:e7:7c:71:84:08:d3:c3:b7:df" -passive=1 -timeout=15
. 2021-04-21 16:10:51.095 --------------------------------------------------------------------------
. 2021-04-21 16:10:51.095 Session name: ****@****(Ad-Hoc site)
. 2021-04-21 16:10:51.095 Host name: ****(Port: 990)
. 2021-04-21 16:10:51.095 User name: **** (Password: Yes, Key file: No, Passphrase: No)
. 2021-04-21 16:10:51.095 Transfer Protocol: FTP
. 2021-04-21 16:10:51.095 Ping type: Dummy, Ping interval: 30 sec; Timeout: 15 sec
. 2021-04-21 16:10:51.095 Disable Nagle: No
. 2021-04-21 16:10:51.095 Proxy: None
. 2021-04-21 16:10:51.095 Send buffer: 262144
. 2021-04-21 16:10:51.095 UTF: Auto
. 2021-04-21 16:10:51.095 FTPS: Implicit TLS/SSL [Client certificate: No]
. 2021-04-21 16:10:51.095 FTP: Passive: Yes [Force IP: Auto]; MLSD: Auto [List all: Auto]; HOST: Auto
. 2021-04-21 16:10:51.095 Session reuse: Yes
. 2021-04-21 16:10:51.095 TLS/SSL versions: TLSv1.0-TLSv1.2
. 2021-04-21 16:10:51.095 Local directory: default, Remote directory: home, Update: Yes, Cache: Yes
. 2021-04-21 16:10:51.095 Cache directory changes: Yes, Permanent: Yes
. 2021-04-21 16:10:51.095 Recycle bin: Delete to: No, Overwritten to: No, Bin path: 
. 2021-04-21 16:10:51.095 Timezone offset: 0h 0m
. 2021-04-21 16:10:51.095 --------------------------------------------------------------------------
. 2021-04-21 16:10:51.267 Connecting to ****:990 ...
. 2021-04-21 16:10:51.267 Connected with ****:990, negotiating TLS connection...
. 2021-04-21 16:10:51.861 Verifying certificate for "****" with fingerprint ca:34:2d:f0:7a:4b:56:5a:ee:d2:25:e7:7c:71:84:08:d3:c3:b7:df and 20 failures
. 2021-04-21 16:10:51.861 Certificate common name "****" matches hostname
. 2021-04-21 16:10:51.861 Certificate for "****" matches configured fingerprint
. 2021-04-21 16:10:51.861 Using TLSv1.2, cipher TLSv1/SSLv3: ECDHE-RSA-AES256-GCM-SHA384, 2048 bit RSA, ECDHE-RSA-AES256-GCM-SHA384 TLSv1.2 Kx=ECDH     Au=RSA  Enc=AESGCM(256) Mac=AEAD
. 2021-04-21 16:10:51.861 TLS connection established. Waiting for welcome message...
< 2021-04-21 16:10:51.861 220 Momentum SSL/TLS FTP Service Ready. (Implicit Mode)
> 2021-04-21 16:10:51.861 USER ****
< 2021-04-21 16:10:51.861 331 User name okay, need password.
> 2021-04-21 16:10:51.861 PASS *************
< 2021-04-21 16:10:51.892 230-Credentials accepted.
< 2021-04-21 16:10:51.892 230 User logged in, proceed.
> 2021-04-21 16:10:51.892 SYST
. 2021-04-21 16:10:51.892 The server is probably running Windows, assuming that directory listing timestamps are affected by DST.
< 2021-04-21 16:10:51.892 215 Windows_NT
> 2021-04-21 16:10:51.892 FEAT
< 2021-04-21 16:10:51.892 502 Command not implemented.
> 2021-04-21 16:10:51.892 PBSZ 0
< 2021-04-21 16:10:51.892 200 Command accepted, PBSZ=0
> 2021-04-21 16:10:51.892 PROT P
< 2021-04-21 16:10:51.892 200 Command okay.
. 2021-04-21 16:10:51.892 Connected
. 2021-04-21 16:10:51.892 --------------------------------------------------------------------------
. 2021-04-21 16:10:51.892 Using FTP protocol.
. 2021-04-21 16:10:51.892 Doing startup conversation with host.
> 2021-04-21 16:10:51.892 PWD
< 2021-04-21 16:10:51.892 257 "E:/MSL/PrivateMB/****up" is current directory.
. 2021-04-21 16:10:51.892 Getting current directory name.
. 2021-04-21 16:10:51.892 Startup conversation with host finished.
< 2021-04-21 16:10:51.892 Script: Active session: [1] ****@****
> 2021-04-21 16:10:51.939 Script: pwd
< 2021-04-21 16:10:51.939 Script: E:/MSL/PrivateMB/****up
> 2021-04-21 16:10:58.964 Script: put -delete -nopermissions -preservetime -transfer="binary" -- "E:\TEMP\20200415_****_FILE_R.csv" "E:/MSL/PrivateMB/****up/application_request"
. 2021-04-21 16:10:58.964 Copying 1 files/directories to remote directory "E:/MSL/PrivateMB/****up/" - total size: 0
. 2021-04-21 16:10:58.964   PrTime: Yes; PrRO: No; Rght: rw-r--r--; PrR: No (No); FnCs: N; RIC: 0100; Resume: S (102400); CalcS: No; Mask: application_request
. 2021-04-21 16:10:58.964   TM: B; ClAr: No; RemEOF: No; RemBOM: No; CPS: 0; NewerOnly: No; EncryptNewFiles: Yes; ExcludeHiddenFiles: No; ExcludeEmptyDirectories: No; InclM: ; ResumeL: 0
. 2021-04-21 16:10:58.964   AscM: *.*html; *.htm; *.txt; *.php; *.php3; *.cgi; *.c; *.cpp; *.h; *.pas; *.bas; *.tex; *.pl; *.js; .htaccess; *.xtml; *.css; *.cfg; *.ini; *.sh; *.xml
. 2021-04-21 16:10:58.964 File: 'E:\TEMP\20200415_****_FILE_R.csv' [2021-04-01T14:31:52.997Z] [0]
. 2021-04-21 16:10:58.964 Copying "E:\TEMP\20200415_****_FILE_R.csv" to remote directory started.
. 2021-04-21 16:10:58.964 Binary transfer mode selected.
. 2021-04-21 16:10:58.964 Starting upload of E:\TEMP\20200415_****_FILE_R.csv
> 2021-04-21 16:10:58.964 TYPE I
< 2021-04-21 16:10:58.964 200 Command okay.
> 2021-04-21 16:10:58.964 PASV
< 2021-04-21 16:10:58.964 227 Entering Passive Mode (209,202,9,32,19,160)
> 2021-04-21 16:10:58.964 STOR application_request
. 2021-04-21 16:10:58.964 Connecting to 209.202.9.32:5024 ...
< 2021-04-21 16:10:58.981 550 Requested action not taken.  The file could not be opened or created.
. 2021-04-21 16:10:58.981 Copying files to remote side failed.
* 2021-04-21 16:10:58.981 (ExtException) **Copying files to remote side failed.**
* 2021-04-21 16:10:58.981 Requested action not taken.  The file could not be opened or created.
. 2021-04-21 16:10:58.981 Asking user:
. 2021-04-21 16:10:58.981 Error transferring file 'E:\TEMP\20200415_****_FILE_R.csv'. ("Copying files to remote side failed.","Requested action not taken.  The file could not be opened or created.")
< 2021-04-21 16:10:58.981 Script: Error transferring file 'E:\TEMP\20200415_****_FILE_R.csv'.
< 2021-04-21 16:10:58.981 Script: Copying files to remote side failed.
 
< 2021-04-21 16:10:58.981 Requested action not taken.  The file could not be opened or created.
* 2021-04-21 16:10:58.981 (ESkipFile) Error transferring file 'E:\TEMP\20200415_****_FILE_R.csv'.
* 2021-04-21 16:10:58.981 Copying files to remote side failed.
* 2021-04-21 16:10:58.981 Requested action not taken.  The file could not be opened or created.
. 2021-04-21 16:10:58.981 Copying finished: Transferred: 0, Elapsed: 0:00:00, CPS: 0/s
. 2021-04-21 16:10:58.981 Script: Failed 
I'm not sure what I'm missing...

Reply with quote

Advertisement

rsford31

"Requested action not taken" Message when Uploading Files

I figured it out... the destination paths in the CSV file didn't end with /. Once I added them to each of the paths, there was no issue.

Reply with quote

Advertisement

You can post new topics in this forum