Help transferring files using wildcards in PowerShell

Advertisement

doughorton
Joined:
Posts:
4
Location:
Richmond, VA, USA

Help transferring files using wildcards in PowerShell

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:

$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!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,392
Location:
Prague, Czechia

Re: Help transferring files using wildcards in PowerShell

$transferOptions.FileMask = "90_FINISH.CHECKS.ISSUED_*,90_FINISH.AP.DETAILS_*"
...
$sourcepath = "/data/STORAGE/_HOLD_/*"

Reply with quote

doughorton
Joined:
Posts:
4
Location:
Richmond, VA, USA

Re: Help transferring files using wildcards in PowerShell

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.

Reply with quote

martin
Site Admin
martin avatar

Re: Help transferring files using wildcards in PowerShell

You are welcome. Thanks for considering a donation to our project!

Reply with quote

Advertisement

You can post new topics in this forum