AX 2012 Export and Import a Model files
A model is a set of elements in a given layer. Each layer consists of one or more models. Models can be exported to files that have the .axmodel extension. These files are called model files. Model files are deployment artifacts that can be imported into a model store.
A model is permanently associated with the layer that is created in. If you need to move one of your models from one layer to another, you must create a project from the model in the AOT, export the project as an xpo file, create a target model in the desired layer, delete the original model to avoid having to resolve layer conflicts, and import the xpo file to the target model. If you are moving elements between models in the same layer, you can use the Move to model command in the AOT.
You can use either Windows PowerShell cmdlets or the AXUtil command-line utility to export models to model files and import model files into a model store.
Export an .axmodel file (Windows PowerShell)
- On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
- At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
Windows PowerShell
Export-AXModel –Model > -File > -Details
This example exports the specified model to a file that has the specified file name.
You can use the -Key parameter to specify the strong-name key pair file to use to sign a model.
- You can also use the Sign Tool to sign the file with a digital certificate, or the AXUtil genlicense command to Authenticode sign a file.
Export an .axmodel file (AXUtil)
- On the Start menu, click Command prompt.
- Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
- At the command prompt, type the following command, and then press ENTER.
4. axutil export /model: /file: /verbose
This example exports the specified model to a file that has the specified file name.
You can use the [/key:SNK-file] parameter to specify the strong-name key pair file to use to sign a model.
5. You can also use the Sign Tool to sign the file with a digital certificate, or the AXUtil genlicense command to Authenticode sign a file.
By default, when you import a model from Windows PowerShell or AXUtil, the installation mode is set to display the Model code upgrade checklist when the Microsoft Dynamics AX client starts. If you import a model by using Setup.exe, by default, the installation mode does not display the Model code upgrade checklist.
Import an .axmodel file (Windows PowerShell)
- On the Start menu, point to All Programs, point to Administrative Tools, and then click Microsoft Dynamics AX Management Shell.
- At the Windows PowerShell command prompt, PS C:\>, type the following command, and then press ENTER.
Windows PowerShell
Install-AXModel -File > -Details
This command installs the specified file in the same layer that it was exported from.
By default, you will be prompted to install the model based on whether it has been signed. The following table describes the prompts shown.
If the installation fails because of a conflict, we recommend that you rerun the cmdlet, and use the -Conflict Push option to push the element that has the conflict to the related update layer. You can then resolve the conflict
Ex:
Install-AXModel -File C:\temp\MK_Patch5_AX2012R3CU11.axmodel -Details
Ex:
Install-AXModel -File C:\temp\MK_Patch5_AX2012R3CU11.axmodel -Details
Import an .axmodel file (AXUtil)
- On the Start menu, click Command prompt.
- Navigate to the directory for the management utilities. Typically, the location of this directory is %ProgramFiles%\Microsoft Dynamics AX\60\ManagementUtilities.
- At the command prompt, type the following command, and then press ENTER.
4. axutil import /file: /verbose
This command installs the specified file in the same layer that it was exported from.
If the installation fails because of a conflict, we recommend that you rerun the command, and use the /conflict:push option to push the element that has the conflict to the related update layer. You can then resolve the conflict
When you import a model, elements in the model that you are importing may conflict with another model in the same layer. In this situation, you can create a conflict modelin the patch layer that is associated with the layer that you are working in. You can then resolve the conflicts in the conflict model.
For More information:
Export Import-AXModelStore
Syntax
Parameter Set: Default
Import-AXModelStore [-Apply
Examples
Import Model store
PS C:\Windows\system32> Import-AXModelStore -File P:\SCAX2012_model.axmodelstore
Syntax
Parameter Set: Default
Export-AXModelStore -File
Examples
Export Model StoreCommand
PS C:\Windows\system32> Export-AXModelStore -File P:\SCAX2012_model.axmodelstore -Database SCAX2012_model -Details
With SQL server running on different system
Export-AXModelStore -File C:\Temp\SCAX2012_model.axmodelstore -Server tscAX2012dbs -Database SCAX2012_model -Details
https://technet.microsoft.com/en-us/library/jj720286.aspx
https://technet.microsoft.com/en-us/library/jj720259.aspx
PowerShell commands
Here I'll start a collection of useful PowerShell commands:
Get-Content writes the content of a file to PowerShell window:
Get-Content c:\scripts\test.txt - wait
To get the last x lines use Select-Object - last x: (it might take some time :) )
Get-Content c:\scripts\test.txt | Select-Object -last 5
Microsoft Dynamics AX 2012 Management Shell
Model Content:
(Get-AXModel -Model "USR Model" -Details).Elements | Out-String
Uninstall-AXModel -Database "NameOfDB" -Model "NameOfModel"
you could always use -Config AOSName or -Database "NameOfDB".
to overwrite existing elements in a model use -conflict: overwrite
Get-Content writes the content of a file to PowerShell window:
Get-Content c:\scripts\test.txt - wait
To get the last x lines use Select-Object - last x: (it might take some time :) )
Get-Content c:\scripts\test.txt | Select-Object -last 5
Microsoft Dynamics AX 2012 Management Shell
List Models
Get-AXModel -Config AOSNameModel Content:
(Get-AXModel -Model "USR Model" -Details).Elements | Out-String
Install / Uninstall a model
Install-AXModel -File Filename.axmodel -Config AOSNameUninstall-AXModel -Database "NameOfDB" -Model "NameOfModel"
you could always use -Config AOSName or -Database "NameOfDB".
to overwrite existing elements in a model use -conflict: overwrite
Export a model
Export-AXModel –Model "NameOfModel" -File "FileName"
you could always use -Config AOSName or -Database "NameOfDB".Export a modelstore
Export-AXModelStore -Config AOSName -File Filename.axmodelstore -Details
With SQL server running on different system
Export-AXModelStore -File C:\Temp\SCAX2012_model.axmodelstore -Server tscAX2012dbs -Database SCAX2012_model -Details
Import a modelstore
Stop the AOS for the import
Import-AXModelStore -Config AOSName -File Filename.axmodelstore
To reduce the downtime of the AOS the modelstore could be imported to a temporary schema
Import-AXModelStore -File Filename.axmodelstore -SchemaName TemporarySchema
Drain all client connections from the AOS instance and apply the temporary schema
Import-AXModelStore -Apply:TemporarySchema -Config AOSName
Import Model store with ID Conflit
Import-AXModelStore -File F:\ModelStore\SCAX2012_model.axmodelstore -IdConflict Overwrite
SSRS Reports
Get a List of Reports starting with A and store it in a variable
$reports = Get-AXReport -ReportName A* -ServicesAOSWSDLPort 8109
To view the List
$reports
Deploy Reports:
Publish-AXReport -ReportName CustTransList -ServicesAOSWSDLPort 8109
$reports = Get-AXReport -ReportName A* -ServicesAOSWSDLPort 8109
To view the List
$reports
Deploy Reports:
Publish-AXReport -ReportName CustTransList -ServicesAOSWSDLPort 8109
2 comments:
No need to write any command. Try out this GUI interface http://www.42hertz.com/posts/42hertz-dynamics-ax-model-import-export/
Import/Export models without powershell/AXUtil inside AX client.:) http://www.42hertz.com/posts/42hertz-dynamics-ax-model-porter/. Thanks 42hertz INC
App URL: http://store.42hertz.com/collections/ax-modules/products/42hertz-dynamics-ax-model-porter
Post a Comment