Upload FTP file based on extensions in PowerShell

We used the following link to monitor the FTP folder and download files from it:
https://jhonatantirado.wordpress.com/2013/12/18/download-and-delete-files-from-ftp-using-powershell/

I need to download only .xml .

I am very new to PowerShell, nothing simple that I am missing?

 if ($line -ne ''| $_.extension -eq '.bpxml-2014' -or $_.extension -eq '.xml') { } 

$line has my filename with the extension. How to check if it has an extension?

0
source share
2 answers

Windows includes an FTP command line client. It can be launched using the script command. Use the -s switch to specify a script file.

A command like mget *.xml should be a good start.

0
source

Using

 if ($line -Like "*.xml" -or $line -Like ".bpxml-2014") { ... } 

See PowerShell comparison operators .


Alternatively, see (my) solution using the WinSCP.NET assembly used in the PowerShell script:
List of files matching the pattern

And just upload the appropriate files using Session.GetFiles .

0
source

Source: https://habr.com/ru/post/983160/


All Articles