A new Flexera Community experience is coming on November 18th, click here for more information.
I have been able to create a scheduled task to run the import but what can I do to have it run only if there is a file to run. There may not be files to run everyday. I don't know how to write powershell.
‎Feb 09, 2024 08:12 AM
checking the file works but when I do a start-process MGSBI.exe /Import=POImport /ConfigFile=create_purchase.xml it keeps saying it [A positional parameter cannot be found that accepts argument '/ConfigFile=Create_Purchase.xml'] I tried it with quotes and without quotes the file is in the same location as the MGSBI.EXE because when I listed it with the path and file it didn't work.
‎Feb 13, 2024 09:54 AM
I tried my Powershell file with a call to MGSBI and it did run. I've substituted your parameters in it; you simply need to enter the file path to the file you're checking for and that of your business adapter's XML. The file I provided does not use start-process; it calls MGSBI natively as part of the Powershell file.
If you want to use the start-process cmdlet, then @ppyrzynski 's suggestion should work, or you could call it like this:
Start-Process -Filepath "C:\path\to\mgsbi\MGSBI.exe" -ArgumentList "/Import=POImport /ConfigFile=c:\path\to\your\xml\create_purchase.xml"
--Mark
‎Feb 13, 2024 02:16 PM
Not sue if your start-process code will work like this, have you tired it @mfeinman ? I believe arguments in ArgumentList have to be separated with a comma. Also, if a path contains blank spaces it should be enclosed with single or double quotes, shouldn't it? I'm not a PS expert so if I'm wrong, just let me know.
Paweł
‎Feb 13, 2024 02:44 PM
Parameters can be passed as either a single string separated by spaces or as individual strings separated by commas. Take a look at example 7 here. If there are spaces in the string that don't represent parameters, then yes, they need to be surrounded by double quotes. Bottrm's example didn't have any.
-ArgumentList
Specifies parameters or parameter values to use when this cmdlet starts the process. Arguments can be accepted as a single string with the arguments separated by spaces, or as an array of strings separated by commas. The cmdlet joins the array into a single string with each element of the array separated by a single space.
The outer quotes of the PowerShell strings aren't included when the ArgumentList values are passed to the new process. If parameters or parameter values contain a space or quotes, they need to be surrounded with escaped double quotes.
For the best results, use a single ArgumentList value containing all the arguments and any needed quote characters.
--Mark
‎Feb 14, 2024 08:31 AM
Thanks Mark,
You are, of course, right. Tested and worked.
‎Feb 14, 2024 12:19 PM
Hey. Try this:
$argList=("/Import=POImport", "/ConfigFile=`"<PATH TO YOUR XML FILE>\Create_Purchase.xml`"")
Start-Process "C:\Program Files (x86)\Flexera Software\FNMP Business Adapter Studio\MGSBI.exe" -ArgumentList $argList
‎Feb 13, 2024 12:14 PM
User | Count |
---|---|
8 | |
6 | |
3 | |
3 |