The Import-AXXPO custom PowerShell function allows you to automate the importing of .xpo files. It is going to look very familiar to people who have read some of my other functions as it follows the same format as Compile-AXCIL and Sync-AXDB.
The Import-AXXPO function takes between 2 and 9 parameters:
- ConfigPath (Client configuration for the chosen AX environment)
- LogFile (The value defaults to the temp folder but can be overridden if desired)
- TimeOut (The value defaults to 20 minutes but can be overridden if desired)
- ImportFile (The .xpo file to import)
- Model (The AX model to open in)
- SMTPServer (SMTP server to use to send the email)
- MailMsg (Net.Mail.MailMessage object used to send the email)
- AXVersion (The AX version. It defaults to 6.)
- VariablePath (Path to a file used to default the parameters/variables)
I use the VariablePath parameter the same way that I do in the other functions I’ve posted that use it. This function can be found in Codeplex. The steps of this function are:
- Load the variables if a VariablePath parameter is used
- Validate the ImportFile parameter location
- Get the AX environment info using Get-AXConfig
- Get the CompileIL AX AutoRun xml using the Get-AXAutoRunXML function
- Call the Start-AXAutoRun function to import the .xpo
Some things to consider with this function. Where an .xpo is imported is controlled by 3 things. The configuration file used to open AX will control what layer the .xpo is imported into. The model is controlled by either the Model parameter or the user option “Startup model” (Tools -> Options -> Development -> Startup model). This value is stored per user and per layer so make sure you have this value set up in every AX environment that you will be importing .xpos in if you don’t use the Model parameter.
This function should also only be run on the AOS server. It has been tested using AX 2012 R2 CU7 but should also work for R3.