Cumulative Updates for Microsoft Dynamics NAV with PowerShell

Last month most of our development team spent a few days in Antwerp, home of the impressively grand Antwerp Central Train Station, the self-proclaimed best beer in the world and, temporarily, the NAV TechDays conference.

One of the topics we came home most enthused about (aside from the delicious Oriental cuisine) was PowerShell. Jack, another of our devs, has already posted about customising your PowerShell environment here.

Traditionally, NAV upgrades have been time consuming and labour intensive. With Microsoft releasing a major new version every couple of years it has been a big decision for customers to invest in the upgrade process. That is changing with Microsoft seeking to provide new releases on a more frequent basis with fewer changes between them.

That’s great for end users who are able to get their hands on new features sooner. It’s not so good for NAV DBAs who are having to manage all of these object changes. To give you some idea of how frequent these releases are, cumulative update 14 for NAV 2013 R2 was released the other day. 14 updates for a product that was only released in Q3 of 2013.

Help is at hand in the form of PowerShell. You can import, export, compare, merge, split, join, update and compile objects all from the command line these days.

When Microsoft release a new cumulative update they include the objects that have changed from the RTM version. That’s fine, unless you’ve also made some changes to some of the objects that Microsoft have changed.

Rather than the complete objects for this update, we are really interested in the changes that have been made since a previous version a.k.a. the deltas of the objects. If we could calculate those we could apply only the changes to our current objects and upgrading to the updated version would be a doddle.

The update comes with a change log for the object changes that is marginally more useful than a chocolate teapot, but certainly less fun. Ignore that and use PowerShell instead.

Command Parameters

This script is an example of what you can automate and shows you how easy you can make the upgrade process http://1drv.ms/12MYc2q.

Load the .ps1 file into PowerShell with the Import-Module command and view the “Create-NAVUpdateDeltaFiles” cmdlet in the Command Add On.

 

Specify the parameters:

  • BaseDatabaseName / ServerName: a SQL server instance and database with objects to compare the new objects against to identify the changes e.g. a 2015 RTM database
  • Object File: the path to the text file containing the updated objects. This is supplied with the cumulative update. There is nothing to stop you using this script for other updated objects scenarios as well.
  • Path: a folder for the script to save the results to.
  • TargetDatabaseName / ServerName: optionally a SQL server instance and database with objects that the changes need to be applied to.

The script will:

  1. Split the specified text file into separate objects files and save in them in an Update folder (2)
  2. For each object, export the same object from the Base database and optionally the Target Database (1 & 5)
  3. Compare the Update objects with the Base objects to create delta files, saved in a Delta folder (3) Folders created by PowerShell script
  4. Identify any objects which are new (exist in the Update set but not the Base set) and move them to a separate folder (4)
  5. Apply those deltas to the Target objects and save them in a Result folder (6)
  6. Identify conflict files (because the object has been changed in the Update and the Target) and move them to a separate folder (7)
  7. Combine the Result files into a text file which can be imported into the Target database using the development environment (Result.txt)

There is room for improvement. You could, for instance, change the script to import Result.txt into your target database and compile the objects. With PowerShell, the NAV world is your proverbial oyster.

Leave a Reply