Powershell Script for DMT

I am needing DMT to run when a file is placed ins a specified folder. How do I do this?

You need to set up a ‘file watcher’ service that will trigger when the file is placed in the directory. There are MANY programs and ways to do this. Google will be your best bet to start/learn about this process.

1 Like

Another option is to have your Powershell script run on a timer … like every 5 minutes … and if there is nothing in that folder then just exit. Otherwise run DMT to process the file(s) that are in that directory.


Does the Source file have to be a specific name each time?

not required, but typically is when produced by some other program. It depends more on the method you choose to start DMT when the file arrives.

1 Like

Another question, still on the main topic, but a bit off the original question. I am attempting to run a script that will used Sales Order Combined to update a few fields. I have the file in the correct location and the script doesn’t have nay errors. However, after the PowerShell starts, noting in Epicor gets updated. Here is the script:

$DMTPath = “C:\Epicor*Location*\DMT.exe”
$User = “user”
$Pass = “pass”
$Source = “C:*Location*\DMT-Script Testing.csv”

#Load Data

Start-Process -Wait $DMTPath -ArgumentList “-User=user -Pass=pass -noui -add -update -import"Sales Order Combined” -update -Source $Source -configvalue=Test.sysconfig"

Can you guarantee that the CSV works when you use DMT interactively with those creds?

1 Like

I wouldn’t be surprised to see some goofy a$$ issues with how its reading “Sales Order Combined”.
What I do is to use an object where I set the template name as a variable inside a variable like this and then I don’t have to worry about apostrophes etc.

 #Import Data From From BAQ -> CSV File -> Load in with DMT 
 $DMTPath = "C:\Epicor\Clients\EpicorLIVE\DMT.exe" 
 $User = "usr" 
 $Pass = "pw" 
 Write-Output "Importing Data via File $(get-date)"  
 $Source = "C:\Temp\VAL_Exports\SalesRegion.csv"  
 $Template = "Sales Region"
 $DMTObj = '"{0}"' -f $Template
 Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import=$DMTObj -Source $Source -ConfigValue=Epicor10LIVE" 

in your $Template variable, you’d set it as “Sales Order Combined”. This is nice because it keeps 1 line of code where you change your template name.


Yes, the csv works when done manually and logged in with the user I am trying to pass on via script.

I will give this a shot!

This worked! Curious, can it be set to where no matter the name of the file, it processes it?

I suppose as long as the location is accessible, I haven’t tried it though.

I was able to tweak your script and works very well! IS et this to run on a scheduled task and when the script is ran on the time schedule, and nothing is in the folder, then it just doesn’t work. So, can the script be amended to see if anything is in the folder, if so run, if not, cancel.

1 Like

I’m trying to parse your words, but you’re asking if you can schedule the script to be run (yes) and append the script to first check the source folder for contents (yes)?
You gotta work on your google-fu my dude.

Schedule powershell script:
How to Schedule a PowerShell Script to Auto Run On a Windows Server (itechguides.com)

Check if a folder has contents:
Powershell test if folder empty - Stack Overflow

1 Like


I already have the schedule set up. It is set to run every 5minutes. It was running and working as long as a file was in the folder. When there wasn’t a file, it stopped. When it stopped, it wouldn’t allow the schedule task to restart the 5 minute timer and run again. So I was thinking, run a script to check if a file is in the folder.

If there is a file in the folder, then run the script, else stop and run on te time schedule.
Thank you!

1 Like