Print this Post

NAV 2013 R2: Export objects with PowerShell

NAV 2013 R2: Export objects with PowerShell
3 votes, 2.00 avg. rating (53% score)

A while ago, I create a blog about a way to import objects in NAV with PowerShell. Well, it’s time to do the opposite, and export objects. This is the function I came up with (pardon the formatting – copy/pasting really made it difficult for me…):


I agree .. things can be improved. But I think it’s more than enough to get you going. I think it’s very usable in some kind of automated script where you want to export stuff to for example TFS and back.

The function is going to create one file each time you call it. For example:



This is going to create one file which contains the query-objects in the 700-range.

A way to create single files, is to play with the integers yourself, like this:



It is slow, but then again, it does its job, and there are ways to do it multithreaded in PowerShell as well ;-).

Permanent link to this article: http://www.waldo.be/2014/06/04/nav-2013-r2-export-objects-with-powershell-3/


2 pings

Skip to comment form

  1. Kai Kowalewski

    Works nicely, but a ” seems to be missing in front of C:\Program Files in Line 18.
    I modified the function to include the servername as a fifth parameter and kept getting an error that the path C:\Progam does not exist (Win 7 OS) . After I inserted the ” it worked as planned.

    1. waldo

      It works on my end – but problems could arise when working with different versions of PowerShell. That might be what’s causing it .. .

      Thanks for the comment!

  2. John

    It works perfectly when I call the function but when I just try to use a stripped down command like this:
    cmd /c “C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client\finsql.exe” command=exportobjects,file=C:\asd\\TAB3.txt,servername=myservername,database=mydatabase,Logfile=C:\asd\\Log_TAB3.txt,filter=Type=Table;ID=3

    I get an error saying The text exportobjects,file=C:\asd\\TAB3.txt,servername=myservername,database=mydatabase,Logfile=C:\asd\\Log_TAB3.txt,filter=Type=Table is too long. Text can have a maximum length of 47 characters.

    I just copied the excact same command from the $Command variable when I ran your script. What’s the difference between the two methods?

    1. waldo

      Not sure if I understand correctly. but have you tried to put the c:\asd .. between quotes, like:
      cmd /c “C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client\finsql.exe” command=exportobjects,file=”C:\asd\\TAB3.txt”,servername=myservername,database=mydatabase,Logfile=”C:\asd\\Log_TAB3.txt”,filter=”Type=Table;ID=3″

Leave a Reply

%d bloggers like this: