Powershell commands
Command to list all the elements in the model in AX (Installed )
(Note: here -Model 15 is user layer model)
------------------------------------------------------------------------------------
&"C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"
$s = 'D-WBX-DEV06'
$d = 'Weetabix_Dev_Model'
(get-axmodel -server $s -database $d -model 15 -details).elements | format-table -property path -autosize
--------------------------------------------------------------------------------------------------------------------
Command to list all the elements in the model File (Not Installed).
-------------------------------------------------------------------------------------
(get-axmodel -server $s -database $d -file "C:\Lasernet\Lasernet Connector for Microsoft Dynamics AX2012 R3 CU13\Model\VAR\LAC_VAR_5002_17102018_110314_AX2012R3CU13.axmodel" -details).elements | format-table -property path -autosize
Ex:
$filepath = "F:\DevOpsRepository\Builds\1.0.0.316\Application\Appl\MK.axmodel"
$s= "DataBaseServerName"
$d= "AXDatabaseName"
(get-axmodel -server $s -database $d -file $filepath -details).elements | format-table -property path -autosize | Out-File -FilePath "F:\Tmp\WCC model content.txt" -NoClobber
-------------------------------------------------------------------------------------------------------------
AX DB Sync
---------------------------------------------------------------------------------------------------------
$axProcess = Start-Process -PassThru ($axClientPath + "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe") -ArgumentList ($params + " -StartupCmd=Synchronize")
if ($axProcess.WaitForExit($AXSYNCTIMEOUT) -eq $false)
{
Throw ("Error: Synchronize did not complete within " + $AXSYNCTIMEOUT / 60000 + " minutes")
}
---------------------------------------------------------------------------------------------------------------
Uninstall-AXModel
Install-AXModel
Parameter Set: Default
Install-AXModel -File  [-Config  ] [-Conflict  ] [-CreateParents] [-Database  ] [-Details] [-NoOptimize] [-NoPrompt] [-Replace  ] [-Server  ] [-TargetLayer  ] [ ]         
 
PS C:\>Install-AXModel -File MyModel.axmodel -Conflict Push
 
Export-AXModel
 
Parameter Set: Default
Export-AXModel -File  -Model  [-Config  ] [-Database  ] [-Key  ] [-ManifestFile  ] [-Server  ] [ ]          
PS C:\>Export-AXModel -model Packaging -file c:\models\PackagingSigned.axmodel -key c:\keys\mykey.snk
 
 ----------------------------------------------------------------------------------------------------Command to list all the elements in the model in AX (Installed )
(Note: here -Model 15 is user layer model)
------------------------------------------------------------------------------------
&"C:\Program Files\Microsoft Dynamics AX\60\ManagementUtilities\Microsoft.Dynamics.ManagementUtilities.ps1"
$s = 'D-WBX-DEV06'
$d = 'Weetabix_Dev_Model'
(get-axmodel -server $s -database $d -model 15 -details).elements | format-table -property path -autosize
--------------------------------------------------------------------------------------------------------------------
Command to list all the elements in the model File (Not Installed).
-------------------------------------------------------------------------------------
(get-axmodel -server $s -database $d -file "C:\Lasernet\Lasernet Connector for Microsoft Dynamics AX2012 R3 CU13\Model\VAR\LAC_VAR_5002_17102018_110314_AX2012R3CU13.axmodel" -details).elements | format-table -property path -autosize
Ex:
$filepath = "F:\DevOpsRepository\Builds\1.0.0.316\Application\Appl\MK.axmodel"
$s= "DataBaseServerName"
$d= "AXDatabaseName"
(get-axmodel -server $s -database $d -file $filepath -details).elements | format-table -property path -autosize | Out-File -FilePath "F:\Tmp\WCC model content.txt" -NoClobber
-------------------------------------------------------------------------------------------------------------
AX DB Sync
---------------------------------------------------------------------------------------------------------
$axProcess = Start-Process -PassThru ($axClientPath + "C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\Bin\Ax32.exe") -ArgumentList ($params + " -StartupCmd=Synchronize")
if ($axProcess.WaitForExit($AXSYNCTIMEOUT) -eq $false)
{
Throw ("Error: Synchronize did not complete within " + $AXSYNCTIMEOUT / 60000 + " minutes")
}
---------------------------------------------------------------------------------------------------------------
Export list of model elements to Excel using PowerShell
(Get-AXModel -Model 'MyModel' -Details).Elements | select path, elementtype | `Export-Csv -NoTypeInformation -Delimiter ';' c:\mymodel.csv--------------------------------------------------------------------------
Uninstall-AXModel 
Parameter Set: Default
Uninstall-AXModel -Model  [-Config  ] [-Database  ] [-Details] [-Layer  ] [-ManifestFile  ] [-NoPrompt] [-Server  ] [ ]        
PS C:\>Uninstall-AXModel -Model TestModel -Details
 
No comments:
Post a Comment