Skip to main content

I've been trying to run an FME Workspace using PowerShell but I'm getting errors. At the moment, it's just a test Workspace with a Creator and an Emailer.

When the FMW is on a different server in a different domain, I get an error saying the FMW file could not be opened. I am mapping a drive to the other server in the PowerShell console before I try to run the Workspace.

When the FMW is on the same server as the EXE and PowerShell window, I get "A fatal error has occurred. Check the logfile..." although the Workspace did seem to have completed.

I've tried the same things in a Command Prompt window with no errors so I'm going to use a Batch File for now.

Can you be a bit more specific?


Hello @tim_wood,

 

As @david_r suggested, are you able to be more specific/provide more details? Using a simple workspace(creator and logger) I was able to successfully run an FME workspace using Windows PowerShell. I also tried running a workspace that was hosted on a network drive and it was successful as well.

Hello @tim_wood,

 

As @david_r suggested, are you able to be more specific/provide more details? Using a simple workspace(creator and logger) I was able to successfully run an FME workspace using Windows PowerShell. I also tried running a workspace that was hosted on a network drive and it was successful as well.
Thanks both.

 

I'm running it on Windows Server 2008 and have found differences between PowerShell there and code samples from the internet which I think are for later versions of Server/PowerShell.

 

I'm trying to use PowerShell or a batch file to script the running of FME because I want to run the Workspace as a Scheduled Task. Our server team believes authentication issues a preventing this from working directly i.e. specifying fme.exe and the FMW in the task, and have suggested calling a script which will map a network drive and run the Workspace.

 

Now I know it's possible with PowerShell I'll continue working on it.

 


Hi @tim_wood,

It is also very easy to create a batch file from a Workspace. You'll just have to copy the first blue rules from the log file and save them as a batch file. Using Task Manager you can schedule the batch file to run.

The first line describes which model to run using which FME instance. The following lines describe the parameter settings.


I suspect your issue may be more related to the task scheduler than FME, there are some known gotcha's when running powershell and/or batch scripts.

Have a look at e.g. this article for more info on how to run a powershell script from the task scheduler: https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script/


Hi @tim_wood,

It is also very easy to create a batch file from a Workspace. You'll just have to copy the first blue rules from the log file and save them as a batch file. Using Task Manager you can schedule the batch file to run.

The first line describes which model to run using which FME instance. The following lines describe the parameter settings.

Thanks. Normally, I don't even need to use a batch file/PS script, I just call FME and the Workspace direct from Task Scheduler. However in this case I'm trying to conquer this pesky cross domain issue.

 

 


I suspect your issue may be more related to the task scheduler than FME, there are some known gotcha's when running powershell and/or batch scripts.

Have a look at e.g. this article for more info on how to run a powershell script from the task scheduler: https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/11/weekend-scripter-use-the-windows-task-scheduler-to-run-a-windows-powershell-script/

Thanks. I think I've been on that page already when trying to find out how to run an EXE from PowerShell - sometimes Google search results don't have the answer! 😉. I haven't got to the point of putting it into task Scheduler yet. I want to get the PowerShell script working before I set it up as a task.

 

 


I want also to user Powershell instead of .cmd or bat files to run FME scripts embedded in some other powershell functionnality.

 

I have been able to run fme.ex with parameters using below powershell scripting:

 

$FME_CMD = $FME_EXE + " " + $FME_SCRIPT + " " + $FME_OPTIONS

$processFme = cmd.exe /c $FME_CMD 2> $null

 

It works, but I still get an error (not problematic) about the output of the "Translation was SUCCESSFUL" string at the end of the process.

 

Is there a way to handle properly this "Translation was SUCCESSFUL" string ?

 

Reading...

Emptying factory pipeline...

C:\\apps\\FME2020\\fme.exe : Translation was SUCCESSFUL

At D:\\fme_scripts\\adp\\foodtrucks\\food_trucks_update.ps1:5 char:1

+ C:\\apps\\FME2020\\fme.exe D:\\fme_scripts\\adp\\foodtrucks\\food_trucks_upd ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   + CategoryInfo         : NotSpecified: (Translation was SUCCESSFUL:String) C], RemoteException

   + FullyQualifiedErrorId : NativeCommandError

 

 

 


I want also to user Powershell instead of .cmd or bat files to run FME scripts embedded in some other powershell functionnality.

 

I have been able to run fme.ex with parameters using below powershell scripting:

 

$FME_CMD = $FME_EXE + " " + $FME_SCRIPT + " " + $FME_OPTIONS

$processFme = cmd.exe /c $FME_CMD 2> $null

 

It works, but I still get an error (not problematic) about the output of the "Translation was SUCCESSFUL" string at the end of the process.

 

Is there a way to handle properly this "Translation was SUCCESSFUL" string ?

 

Reading...

Emptying factory pipeline...

C:\\apps\\FME2020\\fme.exe : Translation was SUCCESSFUL

At D:\\fme_scripts\\adp\\foodtrucks\\food_trucks_update.ps1:5 char:1

+ C:\\apps\\FME2020\\fme.exe D:\\fme_scripts\\adp\\foodtrucks\\food_trucks_upd ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   + CategoryInfo         : NotSpecified: (Translation was SUCCESSFUL:String) C], RemoteException

   + FullyQualifiedErrorId : NativeCommandError

 

 

 

Hi @p-chessel-vdg​,

It looks like this thread was from a few years ago and you've got a good question. Would you be open to posting it as a new question in the Forums for better visibility?


hi,

I have solved the issue : using the cmd.exe / c command in powershell, i am able to launch fme.exe with parameters and catch the output

 

  $FME_CMD = $FME_EXE + " " + $FME_WORKSPACE + " " + $FME_OPTIONS

   echo $FME_CMD >> $LOG_FILE

$processFme = cmd.exe /c $FME_CMD 2> $null

   echo $processFme >> $LOG_FILE


hi,

I have solved the issue : using the cmd.exe / c  command in powershell, i am able to launch fme.exe with parameters and catch the output

 

   $FME_CMD = $FME_EXE + " " + $FME_WORKSPACE + " " + $FME_OPTIONS

   echo $FME_CMD >> $LOG_FILE

  $processFme = cmd.exe /c $FME_CMD 2> $null

   echo $processFme >> $LOG_FILE

Just be aware that you're launching the regular shell here (not Powershell) as a sub-process through cmd.exe and then letting it start FME for you.

Another option is to use the & call operator in Powershell:

& $FME_EXE  $FME_WORKSPACE  $FME_OPTIONS

This will execute FME directly under Powershell, avoiding one extra layer.

See also https://ss64.com/ps/call.html

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_operators?view=powershell-7#call-operator-


With $FME_CMD = $FME_EXE + " " + $FME_WORKSPACE + " " + $FME_OPTIONS ,

using the native & FME_CMD syntax does not work:

 

I have following error wich lookes linked to passing fme workspace and options:

 

The term 'fme.exe D:\\fme_scripts\\***\\***\\******.fmw --DestDataset_FILEGDB \\\\***\\***\\***\\***.gdb --Connection_GEODATABASE_SDE D:\\fme_ressources\\sde\\******.sde' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

 

The same $FME_CMD string works fine with cmd.exe: $processFme = cmd.exe /c $FME_CMD 2> $null

 

 


With $FME_CMD = $FME_EXE + " " + $FME_WORKSPACE + " " + $FME_OPTIONS , 

using the native & FME_CMD  syntax does not work:

 

I have following error wich lookes linked to passing fme workspace and options: 

 

The term 'fme.exe D:\fme_scripts\***\***\******.fmw --DestDataset_FILEGDB \\***\***\***\***.gdb --Connection_GEODATABASE_SDE D:\fme_ressources\sde\******.sde' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

 

The same $FME_CMD string works fine with cmd.exe:  $processFme = cmd.exe /c $FME_CMD 2> $null

 

 

Is it possible that you're doing this?

& $FME_CMD

That would not work and I would expect the error shown. The command will have to be exactly as I posted above:

&  $FME_EXE  $FME_WORKSPACE  $FME_OPTIONS

 There's a small possibility that you'll have to also split up the different option key/pairs. So in the end it's a trade-off between beeing pragmatic and being efficient :-)


When I perform an & $FME_EXE + $FME_WORKSPACE + $FME_OPTIONS

I get an error related to wrong number of parameters (even) , this error does not appear with cmd.exe /c

 

fme.exe :

At D:\\fme_scripts\\***\\\\*****.ps1:32 char:5

+    & $FME_EXE + $FME_WORKSPACE + $FME_OPTIONS

+    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

   + CategoryInfo         : NotSpecified: (:String) S], RemoteException

   + FullyQualifiedErrorId : NativeCommandError

 

Expected an even number of command line arguments, instead got 3 for command line: >> `D:\\fme_scripts\\***\\***.fmw' `+' 

`--DestDataset_FILEGDB \\\\***\\***.gdb --Connection_GEODATABASE_SDE_ADP

D:\\fme_ressources\\sde\\***.sde' <<

Program Terminating

Translation FAILED.


Is it possible that you're doing this?

& $FME_CMD

That would not work and I would expect the error shown. The command will have to be exactly as I posted above:

&  $FME_EXE  $FME_WORKSPACE  $FME_OPTIONS

 There's a small possibility that you'll have to also split up the different option key/pairs. So in the end it's a trade-off between beeing pragmatic and being efficient :-)

Yes,if i split the options it works.

So now i don't need to use the cmd.exe /c , native powershell & is fine.

Thanks

 

 & $FME_EXE $FME_WORKSPACE $FME_OPTION_1 $FME_OPTION_2 2> $null


Reply