Topic "Help transferring files using wildcards in PowerShell"

Author Message
doughorton
[View user's profile]

Joined: 2016-05-03
Posts: 4
Location: Richmond, VA, USA
I'm having a heck of a time getting this to work. I have a folder on an AIX system (/data/STORAGE/_HOLD_) with files that need to be transferred to a folder on my local system (C:\ToProcess).

I need to transfer only the files starting with "90_FINISH.CHECKS.ISSUED_" and "90_FINISH.AP.DETAILS_".

The code I have thus far is:

Code:
$SessionOptions.DisableVersionCheck
$sessionOptions = New-Object WinSCP.SessionOptions
$sessionOptions.Protocol = [WinSCP.Protocol]::sftp
$sessionOptions.HostName = "host"
$sessionOptions.UserName = "user"
$sessionOptions.Password = "password"
$sessionOptions.SshHostKeyFingerprint = "XXXXXX"
$session = New-Object WinSCP.Session
$session.Open($sessionOptions)
$transferOptions = New-Object WinSCP.TransferOptions
$transferOptions.FileMask = "|90_FINISH.CHECKS.ISSUED_*","|90_FINISH.AP.DETAILS_*"
$transferOptions.ResumeSupport.State = [WinSCP.TransferResumeSupportState]::Off
$sourcepath = "/data/STORAGE/_HOLD_"
$destpath = "c:\ToProcess\"

$session.PutFiles($sourcepath, $destpath, $True, $transferOptions)


Once this completes, a new empty folder is created under C:\ToProcess, but no files. I need the files in the root of that folder, not in a "_HOLD_" subfolder.

Help please!
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
$transferOptions.FileMask = "90_FINISH.CHECKS.ISSUED_*,90_FINISH.AP.DETAILS_*"
...
$sourcepath = "/data/STORAGE/_HOLD_/*"
doughorton
[View user's profile]

Joined: 2016-05-03
Posts: 4
Location: Richmond, VA, USA
martin wrote:
$transferOptions.FileMask = "90_FINISH.CHECKS.ISSUED_*,90_FINISH.AP.DETAILS_*"
...
$sourcepath = "/data/STORAGE/_HOLD_/*"


That worked. Thanks! By the way, I am going to get approval from my boss to make a donation. You have been very helpful on several occasions, and I much appreciate it.
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 25034
Location: Prague, Czechia
You are welcome. Thanks for considering a donation to our project!
Advertisements

You can post new topics in this forum






Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License