Import-NAVModules: An easy way to import NAV PowerShell modules

I seem to remember that I have told you that I have created some modules in PowerShell to make my (and your) life easier in Microsoft Dynamics NAV.. ;-).

Well – it seems that these modules are getting some traction. They are available on Github, and the PowerShell Gallery – and people seem to be downloading them quite a lot.

Now, I had the pleasure of someone that added some very interesting functionality. Functionality that I had been working on, but I wasn’t able to get it working like the way I wanted it. Namely an easy way to import the NAV Powershell Modules. You know, when working in PowerShell ISE (or VSCode these days), you always need to load Microsoft’s commandlets by using code like this:

Import-Module "${env:ProgramFiles(x86)}\Microsoft Dynamics NAV\100\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1" -WarningAction SilentlyContinue | out-null
Import-Module "$env:ProgramFiles\Microsoft Dynamics NAV\100\Service\NavAdminTool.ps1" -WarningAction SilentlyContinue | Out-Null
Import-Module "${env:ProgramFiles(x86)}\Microsoft Dynamics NAV\100\RoleTailored Client\Microsoft.Dynamics.Nav.Apps.Tools.psd1" -WarningAction SilentlyContinue | Out-Null

E-ve-ry single time when you open the PowerShell ISE environment you need to load these modules. Sure there are ways to do that automatically – but you see as well that it’s bound to a version. This is just cumbersome.. .

I wanted to have an easy function “Import-NAVModules” that does just that – that figures out what you have installed on the system, and loads the module in the background.

The problem I had was the scope – I didn’t seem to be able to load the modules in the global scope. So, I was able to find and load the modules – but only in the function that was executing. When the function was done – my runspace still wasn’t loaded with the NAV modules..

And then there was Koubek

He forked into my modules on github, fixed my problem .. and even went one or two steps further.. and offered to import his changes with a pull request. Happy days :-). The function now figures out all versions on your system .. if you have multiple versions, it will let you select the version of NAV of which you want to load the PowerShell modules of .. and you can go from there.. . How cool is that :-). Working with multiple versions of NAV on one system just became a lot easier. I have to say it – I love the community :-).

A short demo:


I use this function every single day. The only thing I do now when I open PowerShell, is simply “Import-NAVModules” and all the default NAV commandlets are available to me.. . And if you have multiple versions installed .. you get to choose which version, like demonstrated in this screenshot:


You want this as well?

It’s all online. The easiest way to get my modules on your machine, is by simply execute this in PowerShell:

Find-Module | where author -eq waldo | install-module

Or you can also just download them (or fork) on github:

5.00 avg. rating (98% score) - 3 votes

Permanent link to this article:


1 ping

  1. Yes, the community is really powerful. Two years ago I didn’t see it as a something too relevant (sorry for being so blind) but today I am pretty sure the community is really SOMETHING…

      • waldo on June 30, 2017 at 8:40 pm

      Thanks for the contribution, Jakub!

  1. […] An Easy Way to Import NAV PowerShell Modules […]

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.