Pages

Monday, October 14, 2013

Simple PowerShell deployment script for AOD based AX versions (i.e. earlier than AX 2012)

This is just a simple script to ease the manual steps you'd otherwise go through to move an application from DEV to TEST.

$servicenameDEV = "AOS`$01"
$servicenameTEST = "AOS`$02"

Stop-Service $servicenameDEV
Stop-Service $servicenameTEST

$sourcepath = "\\server\applicationfolder\Application\TEST\Appl\AXTEST\" 
$sourceaodpath = $sourcepath + "*.aod"
$sourcelabelpath = $sourcepath + "axvar*.*"
$targetpath = "\\server\applicationfolder\Application Backup\TEST"

echo "Backup AOD files"
Copy-Item $sourceaodpath -Destination $targetpath -Verbose

echo "Backup Labels"
Copy-Item $sourcelabelpath -Destination $targetpath -Verbose

$sourcepath = "\\server\applicationfolder\Application\DEV\Appl\AXDEV\" 
$sourceaodpath = $sourcepath + "*.aod"
$sourcelabelpath = $sourcepath + "axvar*.*"
$targetpath = "\\egdev\HEALTH\AX40TEST\Application\TEST\Appl\AXTEST"

echo "Copy AOD files from DEV"
Copy-Item $sourceaodpath -Destination $targetpath -Verbose

echo "Copy label files from DEV"
Copy-Item $sourcelabelpath -Destination $targetpath -Verbose

Start-Service $servicenameDEV
Start-Service $servicenameTEST

echo ""
echo "Synchronize AX"
& "C:\Program Files (x86)\Microsoft Dynamics AX\40\Client\Bin\ax32.exe" \\server\AXCONFIGS\AX_40_TEST_VAR.axc -startupcmd=Synchronize

No comments: