cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 7

MFT Server triggered events : Powershell parameters which include Parenthesis() doesn't work

Scenario :

when a file is uploaded to a SFTP account  I would like to trigger a "File Uploaded "event and execute command action and use the build-in Servu- $FileName variable to pass the name of a file

and replace a existing string in another File.

I use the following command line parameters

-noprofile -executionpolicy unrestricted -noninteractive -Command  cat c:\testing\static.txt |%{$_-replace "random",$FileName} > C:\testing\define.txt

The above command works perfectly if i run it directly in PowerShell, but not in Serv-U

The contents of static.txt is :

$client = "random"

So If the filename of the file which is uploaded is  tony.pdf,  then the contents of define.txt should be

$client = "tony.pdf"

Unfortunately  I'm getting this :

$client =  ""

I've tried pasting the command  and parameters in a PowerShell script and then running the script in serv-u however it doesn't work it loses the variable

.

I think the issue has to do with special characters or parenthesis in Servu, because I've tested the following command and it works:

Command echo "$FileName" >> c:\testing\input.txt

Please help

Tony

0 Kudos
2 Replies
Level 12

I'm not sure if Serv-U is capable on running Powershell scripts.  In Orion, there is a special type of action to run Powershell script(alerting) and it is separate with simply running an executable file or a bat file.

Hi Don

Thanks for your feedback

Serv-MFT is capable of running PowerShell Scripts through its triggerd events. I've used it in the past

0 Kudos