Dynamics Ax Management Shell powershell tips


Hi all,

When Dynamics Ax 2012 came out it was shipped with 2 tools AxUtil.exe and the Management shell. In my experience most of the Dynamics Ax developers are already familiar with AxUtil.exe but don’t have much experience in powershell yet. Therefor I decided to write some examples to get you guys going. If you have any questions or a request please leave a comment, I might also add some scripts as I go.

# Load the Management utilities in to a standard powershell session
# If you use the management shell you don't need this
$dynamicsSetupRegKey = Get-Item "HKLM:\SOFTWARE\Microsoft\Dynamics\6.0\Setup"
$sourceDir = $dynamicsSetupRegKey.GetValue("InstallDir")
$dynamicsAXUtilPath = Join-path $sourceDir "ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"
.$dynamicsAXUtilPath

# List all the models like the AxUtil does
Get-AXModel  | Sort-Object ModelId | Format-Table -Property ModelId,Layer,Name,DisplayName,Version -AutoSize

# List all the models like the AxUtil does but filter out the Sys and Syp
Get-AXModel | Where {$_.Layer -NotLike "Sy*"}  | Sort-Object ModelId | Format-Table -Property ModelId,Layer,Name,DisplayName,Version -AutoSize

# Get all elements in a model file
$models = Get-AXModel -File C:\Temp\model.axmodel -Details
$models.Elements | Format-Table -Property Path

Code language: PowerShell (powershell)

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.