How to select DMT database using Powershell

I wanting to use powershell to open DMT and import labor details into Epicor. I’m starting with the examples shown on the DMT GetHub site. Here’s the base code:
‘’’
dmt Automation Example 1

$DMTPath = “C:\Epicor\ERP11\ERP11.2.200.0\ClientDeployment\Client\DMT.exe”
$User = “”
$Pass = “”
$Source = “C:\Users\svc.epicor\Desktop\Converted DB\DMT TE LaborDtl No Header.xlsx”

load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Delete -Import LaborDtl -Source $Source "
‘’’
When I run this it opens the DMT UI trying to use the wrong database and errors out. How do I tell it to open DMT in the Test database (or any other database)?
We are running DMT 11.2.200.0

This may not be a powershell issue. It appears there are multiple instances of DMT (and client installs) on the server.

I haven’t tested it, but looking at the scripts on github, you might be able to specify which config file to use, which would set your proper database.

1 Like

Thanks! That looks promising. I did get the script to work once. It ran and created labor details but everything had zero hours even though there are hours in the source file. Trying to run the script again and I am getting an error saying it cannot find the file. The file is still in the source location. Here’s my new code, am I missing something?
‘’’
dmt Automation Example 1

$DMTPath = “C:\Epicor\ERP11\LocalClients\KineticPilot\DMT.exe”
$User = “”
$Pass = “”
$Source = “C:\Users\svc.epicor\Desktop\ConvertedDB\LaborDtl.xlsx”

load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Import LaborDtl -NoUI -Source $Source "
‘’’

Does it work if you don’t use the script? (with the zero hours part)

If I open DMT and load the file everything works fine. We are trying to find a way to import labor detail records from our 3rd party payroll system, Paylocity. We are testing the service before we try anything like a REST service.
My goal is to drop a file onto the server, say, weekly and have a powershell script run that would mass import the labor using DMT.
Once we have proof of concept and some checks and balances we would try to automate the process.

I’m very new to powershell but the error I’m getting isn’t about DMT not finding the file its giving an error “LaborDtl not found”. That I think is the table I’m wanting to update in the code:
‘’’
//DMT Automation Example 1

$DMTPath = “C:\Epicor\ERP11\LocalClients\KineticPilot\DMT.exe”
$User = “manager”
$Pass = “manager”
$Source = “C:\Users\svc.epicor\Desktop\ConvertedDB\DMTLaborDtl.xlsx”

//Load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Import LaborDtl -NoUI -Source $Source "
‘’’
The table I created my template from is the LaborDtl table using DMT. Maybe I’m not calling the correct process.

Do you need -add? In DMT if you don’t click add, it will only try to update record.

Also is looks like it’s called TE Labor Detail? How did you figure out the name would be Import LaborDTL?

I inferred that from the powershell examples on the Github site. Their sample code is

#DMT Automation Example 1

$DMTPath = "C:\Epicor\ERP10\LocalClients\ERP10\DMT.exe"
$User = "epicor"
$Pass = "epicor"
$Source = "C:\Temp\Product.csv"
 

#Load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Delete **-Import Part** -Source $Source "

They have -Import Part so I inferred they were choosing the table to update so I choose the LaborDtl table from the DMT template builder.

I also didn’t know about the -Add command.

Part is the name of the DMT though, so I think it’s probably going to be name of the DMT. Because there are multiple DMT templates that can affect that table.

image

And I’m guessing too. I haven’t tested any of this.

1 Like

Thanks for the clarification. Let me rewrite my code and check.

So I’ve changed my code to call for the DMT process TE Labor Detail. When I run the script in Powershell it returns an error “Cannot find TE”.
I think somewhere there was an issue with Powershell not reading spaces between words in the code. Does that sound familiar? We are running DMT version 11.2.200.14

My latest code:


$DMTPath = "C:\Epicor\ERP11\LocalClients\KineticPilot\DMT.exe"
$User = "manager"
$Pass = "manager"
$Source = "C:\Users\svc.epicor\Desktop\ConvertedDB\DMTLaborDtl.xlsx"

#Load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Import TE Labor Detail -Source $Source "```

I finally got it to work. There are lots of little moving pieces that I had to correct.
For anyone wanting to update labor details using Powershell and DMT here is my basic code:

#DMT Automation Example 1

$DMTPath = "<Location of your client folder>\DMT.exe"
$User = "<user>"
$Pass = "<password>"
$Source = "<Location of your source file>"

#Load Data
Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Add -Update -Import `"TE Labor Detail No Header`" -Source $Source "

Another note make sure to have the commands (verbs?) -Add -Update -Import for the DMT to add anything. Also note the name of the DMT you are using follows this. In my case it is "TE Labor Detail No Header". If the DMT name has spaces use the ` with the double quotes " Its next to the “1” on your keyboard. It may be called a “grave marker”??

2 Likes