DMT Powershell Help

So I am trying to create a powershell script to import data into the Product Group table. I use the following script:

Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Delete -Import “Product Group” -Source $Source "

I get this message:
image

So my Import variable is not accepting spaces. How do I get it to except spaces.

It works fine with “Part”, because no spaces.

Thanks!

Have you tried single quotes?

I ended up doing it like this:

$ImportName = ‘“Part Warehouse”’
Start-Process -Wait -FilePath $DMTPath -ArgumentList “-SSO -Add -Import $ImportName -Source $Source1”

Been there done that… it’s a pain.
You need to use the PowerShell escape character, the ‘backtick’ AKA, ‘grave accent.’ This is usually the key to the left of the 1 key.

-Import `"Product Group`"

At Insights last year I did a session on DMT PowerShell and I covered this struggle, examples and such are on my blog:

9 Likes

Thanks! That worked. I did find something about backticks. I didnt know how to lay them out.

Is there a way to run it without the DMT interface popping up?

Yes just include the -NoUI argument:

Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Update -Import `"Sales Order Header`" -NoUI -Source $Source "

I did not include the -NoUI in some of my examples since the Task Scheduler was calling the PowerShell script and so it’s not really needed.

-Rick Bird
www.getaligned.solutions

1 Like

Where can i find a list of arguments?

Mostly on Facebook.

5 Likes

DMT /? will give them to you if run at the command line.

Mark W.

1 Like

So I am trying to get a powershell script to run a simple DMT load (trying to learn something today). I am not having any success, and I can’t really tell what I am doing wrong. Can someone take a quick look at tell my why this wouldn’t work? We run this is DMT all of the time.

$DMTPath = "C:\Epicor\ERP10.2Client\Client\DMT.exe"
$User = "user"
$Pass = "password"
$source = "C:\Users\banderson\Desktop\A1 MasterComment.csv"

Start-Procss -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Update -Import `"Bill Of Operations`" -Source $Source "

never mind. Typo, “Process” :man_facepalming:

Try

Start-Process -Wait -FilePath $DMTPath -ArgumentList "-User $User -Pass $Pass -Update -Import `Bill Of Operations` -Source $Source "

I don’t think you want the double quotes are the Bill of Material, going from memory here.

it worked when I fixed the typo.

1 Like

You didn’t need to go from memory, you just had to scroll up! :laughing: Thanks @Rick_Bird for the examples.

1 Like

ok new problem. I had a inkling that it was spaces in the file location that was giving my a problems, so I copied a sample file and removed spaces. It still didn’t work, so I kept going and found the typo.

Now when I put it back to the actual file name, it bombs out at the space. Is there a way to handle spaces in file name/locations in powershell?

Is it not possible to force the input files to use underscores (or no spaces at all)?

It’s possible. It’s just already set up, so changing it is extra work that I don’t want to do if I don’t have to.

1 Like

I figured as much. If it was me, I’d spend the time figuring out how to pass arguments with quotes in them. Just because I’d refuse to be beat!

How about:

$argList =  "User $User -Pass $Pass -Update -Import `"Bill Of Operations`" -Source `"$Source`" "

In case it’s not obvious, I added the grave and quote, before and after the var $Source, keeping the close quote

EDIT: THIS DON’T WORK!!!

That doesn’t work at all…