VanDyke Software Forums

VanDyke Software Forums (https://forums.vandyke.com/index.php)
-   Scripting (https://forums.vandyke.com/forumdisplay.php?f=14)
-   -   SFXCL and Powershell (https://forums.vandyke.com/showthread.php?t=14240)

jjacobus 07-26-2020 03:10 PM

SFXCL and Powershell
 
Does anyone have any examples of using SFXCL to upload/download/list files with Powershell? I'm having a difficult time figuring out how to pass parameters to the SFXCL command line. In particular I want to get a /LIST of a directory and parse the results to see if a file is present. I'm converting several .BAT files to .PS1

bgagnon 07-26-2020 03:51 PM

Hi jjacobus,

The SFXCL command-line syntax should be the same regardless of the calling app.

What is your SFXCL command-line? In what way is it failing?

There's an example of the /LIST task on our website.

jjacobus 07-27-2020 08:52 AM

Capturing results
 
I figured out the SFXCL command line parameter as variables. (The scope on SET-Variable is different) The key pairs work as before. I can see the result of the list in my log file.

Problem I'm having is capturing the results. In the example:
SFXCL /List sftp://user@host/target_folder 2>&1 | Find ": -"

The "2>&1 Find ": -" bit is what I can't replicate. So this is really a Powershell question.

bgagnon 07-27-2020 09:16 AM

Hi jjacobus,

I think it's the Find command that might have a replacement in PowerShell.

https://docs.microsoft.com/en-us/pow...w=powershell-7

Sounds like you need to use Select-String instead:
Quote:

The Select-String cmdlet searches for text and text patterns in input strings and files. You can use Select-String similar to grep in UNIX or findstr.exe in Windows.
What are your results with:
SFXCL /List sftp://user@host/target_folder 2>&1 | Select-String -Pattern ": -"


All times are GMT -6. The time now is 02:04 AM.