Exporting a Model using powershell

Hi,

I am trying to export a Model using powershell using the folowing command but i am the following exception

PS C:\Windows\system32> Export-AxModel -Model DEV_Model -file C:\DEV_Mode

Export-AxModel : The pipeline has been stopped.

At line:1 char:1

  • Export-AxModel -Model DEV_Model -file C:\DEV_Mode

  • 
    
  • CategoryInfo : OperationStopped: (:slight_smile: [Export-AXModel], Pipeline

StoppedException

  • FullyQualifiedErrorId : The file false does not exist.,Microsoft.Dynamic

s.AX.Framework.Tools.ModelManagement.PowerShell.ExportAXModelCommand

The command itself is correct, the problem must be somewhere else. The error message is confusing, but it indicates that something is wrong about the file. Maybe you can’t create files there?

Figured out this one. There were 3 instances on the server, so had to mention which AOS i needed to extract the Model file from.

Had to use the -Config parameter.

so the command looked something like this

Export-AxModel -Model DEV_Model -file C:\Test\DEV_Model.axmodel -Config ‘InstanceName’

Hi Frodo,

Is it possible to take the .axmodel file from client system.

If yes, can you tell me how to specify the ‘InstanceName’ from client system AX Management Shell

No you cannot export .axmodel from the client system. To give the instance name Open services on the server and look for your AOS service . if you have not changed the default service name it should be like this :

Microsoft Dynamics AX Object Server 6.2$01- MicrosoftDynamicsAX

In this case to export the model you need to run the following command

Export-AxModel -Model DEV_Model -file C:\Test\DEV_Model.axmodel -Config MicrosoftDynamicsAX

Let me know that works for you.

To export models, you’ll need the management shell installed and access to the modelstore database, including sufficient permissions.

The -Config parameter expects an AOS instance name - you can see it (among other places) in the Server Configuration Utility (in parenthesis in Application Object Server Instance field). The cmdlet looks for the value to Windows registry (under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\Dynamics Server\6.0).

Or you can specify the model store database directly by -Database and -Server parameters.

PS C:> Export-AXModel -Model USRmodel -file C:\TEMP\USRmodel.axmodel -Config MicrosoftDynamicsUATAXDB

Export-AXModel : The pipeline has been stopped.

At line:1 char:1

  • Export-AXModel -Model USRmodel -file C:\TEMP\USRmodel.axmodel -Config

MicrosoftD …

  • 
    

+ CategoryInfo : OperationStopped: (:) [Export-AXModel], Pipeline

StoppedException

+ FullyQualifiedErrorId : Model USRmodel not found.,Microsoft.Dynamics.AX.

Framework.Tools.ModelManagement.PowerShell.ExportAXModelCommand

This error persists. Am i doing something wrong? Is the command syntax correct?

Thanks

Ok. Got this to work.

PS C:> Export-AXModel -model “USR Model” -file “C:\modelexp\USRmodel.axmodel”

Config ‘MicrosoftDynamicsUATAXDB’

The above syntax did the trick.

Now the problem is during import.

C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities>axutil import /fil

e:“C:\Model\USRmodel.axmodel” /verbose

AXUtil 6.2 - Microsoft Dynamics AX Admin Utility (6.2.1000.4051)

(c) Copyright, Microsoft Corporation, 2011. All rights reserved.

The AXUtil command was started in the mode: import.

Working against model store WIN-F4VU9IFL6MQ/MicrosoftDynamicsAX_model.

ERROR: Could not load file or assembly ‘C:\Model\USRmodel.axmodel’ or one of its

dependencies. This assembly is built by a runtime newer than the currently load

ed runtime and cannot be loaded.

It does not import models built b y a newer runtime. Anyway to bypass this?