Importing and Exporting NAVData via PowerShell

In my last post I talked about the new export and import features included in Cumulative Update 8 for Microsoft Dynamics NAV 2013 R2, but I did not touch much on the 3 new PowerShell commands that comes with them.

Once you start PowerShell from the menu item installed with the application Type “help Export-NAVData” to get the syntax for the new command Export-NAVData.

So the first question is why there are 4 syntaxes and not just one. Well first you can make the export through the Microsoft Dynamics Server Instance or directly by connecting to the SQL database. Secondly you can be running Multi-tenant or not.

Single Tenant Multi Tenant
Directly to Microsoft SQL Server Database Use Syntax 1 Use Syntax 2
Through Microsoft Dynamics NAV Server Use Syntax 3 Use Syntax 4

 

So why would you need to go directly to SQL you might ask? I mean if you do it from the windows client or via the 2 new commands in C/SIDE you are obviously doing this through the NAV Server and not going directly to the SQL Server. Well one clear case where this could or would be handy would be cases where a tenant in a multi-tenant environment no longer can be mounted because of some issue.

This way you can regain access and figure out what the issues are and get the tenant back online.

Let’s try it out.

Here I am executing a command to export from the database called W12013R2 on my SQL server called SOREN01. I am exporting all companies to a file my.navdata on the temp folder on my C drive.

A process indicator looking like this will be shown while the export is running.

Now you can include the Application, Application Data and Global Data, by adding the optional parameters IncludeApplication, IncludeApplicationData & IncludeGlobalData as seen here

If you have a navdata file and you want to see what is in it you can use the 2ndnew command called Get-NAVDataFile.

Now exporting would not make sense without an import and there we have the last of the 3 new commands Import-NAVData. Let’s try to import this navdata file we just created into an empty database.

First I created a new database on my server called NewDatabase. Secondly I execute the import with the following syntax to rebuild my database from the navdata file.

In my case it asks me if I really want to overwrite and I said yes.

All I need to do now is setup a NAV Server instance and I am good to access my new database.

PowerShell rocks.

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s