Will79
(Will)
October 11, 2021, 1:12pm
1
Is it possible ot havc a powershell script that adds new rows via DMT to a UD table>? If so, waht is that script? I ahve tried
Start-Process -Wait $DMTPath -ArgumentList “-User=Manager -Pass=$DMTPass -Noui -import "UD10
" -AddNew -Source C:\Folder\File.csv -configvalue=Epfake.sysconfig”
and
Start-Process -Wait $DMTPath -ArgumentList “-User=Manager -Pass=$DMTPass -Noui -import "UD10
" -Update -Source C:\Folder\File.csv -configvalue=Epfake.sysconfig”
The first one, doesn’t do anything, the second one errors out saying that it couldn’t find the data in the table.
UPDATE: This worked:
Start-Process -Wait $DMTPath -ArgumentList “-User=Manager -Pass=$DMTPass -Add -Update -import "UD10
" -Update -Source C:\Folder\File.csv -Noui -configvalue=Epfake.sysconfig”
Nancy_Hoyt
(Nancy Hoyt)
October 11, 2021, 1:28pm
2
Hi Will,
IDK if there’s anything special about the UD add new. I’d run it manually via DMT to ensure data going in good, then take it for automation via Powershell.
I have serial number attachment records getting uploaded. I got it going via following this thread from Rick Bird (thanks Rick!), and the code below:
#Load Data via DMT
Start-Process -Wait -FilePath $DMTPath -ArgumentList “-User $User -Pass $Pass -Add -Update -Import "Serial Number Attachment
” -Source $SourcePath -NoUI -ConfigValue=ERP10"
Nancy
1 Like
ckrusen
(Calvin Krusen)
October 11, 2021, 1:53pm
3
On the lines of what @Nancy_Hoyt was saying, the use of variables(that contain strings) in a power shell script can get dicey.
I think the $DMTPass
in the -Arguments
parameter won’t be expanded.
You might want to try making a string variable to hold the all the arguments, and pass that to the Start-Process command.
Edit
Or make it a list of arguments, by separating them with commas(like):
Start-Process -Wait $DMTPath -ArgumentList "-User=Manager", "-Pass="+$DMTPass, "-Noui", "-import", "`"UD10`"", "-AddNew", "-Source C:\Folder\File.csv", "-configvalue=Epfake.sysconfig"
2nd Edit
The MS page says
For the best results, use a single ArgumentList value containing all of the arguments and any needed quote characters.
So maybe the above isn’t the best. but trying to make a string that contains other strings that contain quotation marks can get tricky.
1 Like
ckrusen
(Calvin Krusen)
October 11, 2021, 2:07pm
4
Here’s a good bit on quoted strings in powershell:
2 Likes
Nancy_Hoyt
(Nancy Hoyt)
October 11, 2021, 2:10pm
5
That’s awesome Calvin. Thank you! I really prefer to know why instead of just how
nancy
1 Like