Merging Application Objects using the Example Scripts

The Dynamics NAV product media includes a folder with examples of how you can use Windows PowerShell cmdlets to compare and merge application objects. In the WindowsPowerShellScripts folder on the product media, the ApplicationMergeUtilities folder contains Windows PowerShell sample scripts and folders that contain demonstration data.

You can run the sample scripts from the Microsoft Dynamics NAV Development Shell. Alternatively, you can use the Windows PowerShell Integrated Scripting Environment (ISE) as described in the following section.

The individual scripts provide different variations of how you can use the Dynamics NAV cmdlets. For example, the HowTo-Merge-N-Conflicts-External-Tools.ps1 script shows different ways of displaying conflicts. By opening the scripts in the Windows PowerShell ISE, you can examine the different variations and decide how you want to use the cmdlets to upgrade and maintain your own application.

Using the Sample Scripts in the Windows PowerShell ISE

If you want to use the Windows PowerShell ISE, you must you must import the Microsoft.Dynamics.Nav.Model.Tools.psd1 module. The module installs to the equivalent of C:\Program Files (x86)\Microsoft Dynamics NAV\100\RoleTailored Client when you choose the Developer option in Microsoft Dynamics NAV 2017 Setup.

For example, you can import the module into the Windows PowerShell ISE by typing a command such as the following:

Import-Module "${env:ProgramFiles(x86)}\Microsoft Dynamics NAV\110\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1" -force  

Get-Help "NAV"  

Now you can see the Help for the cmdlets and take a closer look at the examples for how to use them.

The ApplicationMergeUtilities folder contains four subfolders that can help you start working with the scripts. The demonstration data in the ORIGINAL, MODIFIED, and TARGET folders illustrate the text files that are the input to the cmdlets. The demonstration data uses separate text files for each application object, but you can configure the text files in the way that works better for you. For example, you can use the Join-NAVApplicationObjectFile cmdlet to combine all the text files in the MODIFIED folder in a single file, for example, before you run the script.

The HowTo-Start-Import-NAV-Module.ps1 script imports the Microsoft.Dynamics.Nav.Model.Tools.psd1 module into the Windows PowerShell ISE. The __Run-Application-Merge-Utilities.ps1 and __Reset-HowTo-Sample.ps1 scripts enable you to run the sample scripts repeatedly.

For Help for a Dynamics NAV cmdlet, type Get-Help <cmd name>. For Help for the Windows PowerShell ISE, press F1, or choose the Help menu, and then choose Windows PowerShell ISE Help.

See Also

Microsoft Dynamics NAV Windows PowerShell Cmdlets
How to: Merge Application Changes
Comparing and Merging Application Object Source Files