This post is machine-translated. The original post in german language can be found here.

Reading the contents of an AXMODEL file

Microsoft Dynamics AX 2012 Management ShellIf you get a hotfix from Microsoft or a module from a Microsoft partner, you often only get one or more AXMODEL files. And there is often a great desire to know in advance which objects are affected by the import of this file.

Such information can be read with the Microsoft Dynamics AX 2012 Management Shell:

Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details

Here's how it looks:

Manifest                   Summary                    Elements
--------                   -------                    --------
Microsoft.Dynamics.AX.F... {Classes: 3}              {ClassesWHSLoadLineI...

This output isn't very helpful yet, so we'll get a little more detail in our query and now just query the path from the elements container:

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path

Result:

Path
----
ClassesWHSLoadLineInventTransValidator
ClassesWHSLoadLineInventTransValidatorcanSplitLoadLineMultipleTransactions
ClassesWHSLoadLineInventTransValidatorcheckLoadLinesOpenQty
ClassesWHSLoadLineInventTransValidatorclassDeclaration
ClassesWHSLoadLineInventTransValidatorcreateNewLoadLines
ClassesWHSLoadLineInventTransValidatorinit
ClassesWHSLoadLineInventTransValidatorvalidateLoadLineDimensionConsistency
ClassesWHSLoadLineUpdater
ClassesWHSLoadLineUpdatercreateSplitLoadLines
ClassesWHSLoadLineUpdaterinitLoadLine
ClassesWHSLoadPostEngineBase
ClassesWHSLoadPostEngineBase
eserveOrder

 

In the list above you can see that method names are also output. If, for example, I only want to see objects listed, I can do this as follows:

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path, ParentHandle | Where{$_.parenthandle -like 0 }

Result:

Path                                                               ParentHandle
----                                                               ------------
ClassesWHSLoadLineInventTransValid...                                       0
ClassesWHSLoadLineUpdater                                                   0
ClassesWHSLoadPostEngineBase                                                0

 

The automatic adjustment to the output window is still a problem, which leads to the fact that long names are displayed cut off, this can be circumvented as follows:

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path, ParentHandle | Where{$_.parenthandle -like 0 } | format-table -AutoSize

Result:

Path                                     ParentHandle
----                                     ------------
ClassesWHSLoadLineInventTransValidator            0
ClassesWHSLoadLineUpdater                         0
ClassesWHSLoadPostEngineBase                      0

 

If, for example, you only want to output all classes to a text file, you can do this as follows:

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path, ParentHandle, ElementType | Where{$_.elementtype -like "class" } | Where{$_.parenthandle -like 0 } | format-table -AutoSize | out-file c:	empobjects.txt

Of course you can even sort them:

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path, ParentHandle, ElementType | Where{$_.elementtype -like "class" } | Sort-object Path | Where{$_.parenthandle -like 0 } | format-table -AutoSize | out-file c:	empobjects.txt

 

If you want a CSV file instead of a simple text file, this is also possible (you have to omit Format-Table):

(Get-AXModel -File 'c:	empdynamicsax2012r3_cl4555332.axmodel' -Details).Elements | Select-Object Path, ParentHandle, ElementType | Where{$_.elementtype -like "class" } | Sort-object Path | Where{$_.parenthandle -like 0 } | export-csv -path "c:	empobjects.csv" -delimiter "," -notypeinformation -encoding utf8 

And this is how the CSV file looks like:

"Path","ParentHandle","ElementType"
"ClassesWHSLoadLineInventTransValidator","0","Class"
"ClassesWHSLoadLineUpdater","0","Class"
"ClassesWHSLoadPostEngineBase","0","Class"
These post applies to following version:
Dynamics AX 2012

Add comment
 
 

 

 
 
 
Posts of the actual month
April 2024
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.