I created Powershell backup script that iterates the Get-AXModel output and does backups.

Change variables at the top of the file to meet your configuration.

Click the “show source” below to see the code.

backup of ax models.

Gary Holsopple

created 1.18.2012
changed to iterate xml 4/11/2012


import-module "C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"

#region functions
Function New-BackUpFolder($destinationFolder)
$dte = get-date
$dte = $dte.tostring() -replace "[:\s/]", "."
$backUpPath = "$destinationFolder" + $dte
$null = New-Item -path $backUpPath -itemType directory
return $backUpPath
} #end New-BackUpFolder

Function fBackup([string]$model, [string]$fileName, [string]$axEnv)
Export-AXModel -model $model -file $fileName -config $axEnv

#region Variables
$axBackupFolder = "c:\axModelBackup\"
$backupFilePath = New-BackupFolder($axBackupFolder)
$devenv = "DynamicsAX12Development"

[System.Collections.ArrayList] $e = New-Object System.Collections.ArrayList
$e = @("Foundation";
"Foundation Labels";
"Foundation Upgrade";
"Update for Foundation Upgrade";
"Update for Foundation";
"SYP Labels";)

[System.Xml.XmlDocument] $xml
[System.Xml.XmlNode] $obj
[System.Xml.XmlNode] $property


#region do the work

$xml = (Get-AXModel | convertto-xml )
$nodes = $xml.SelectNodes("Objects/Object")

foreach ($obj in $nodes)
foreach ($property in $obj.SelectNodes("Property"))
if ($property.GetAttribute("Name").Equals( "Name" ))
$nameToBackup = $property.InnerText
if ($e.contains($nameToBackup))
$backupFileName = $backupFilePath + "\" + $nameToBackup + ".axmodel"
fBackup $nameToBackup $backupFileName $devenv