«

»

Print this Post

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:

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:

Import-NAVModules

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:

SNAG-0017

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: https://github.com/waldo1001/Cloud.Ready.Software.PowerShell

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

Permanent link to this article: http://www.waldo.be/2017/06/30/import-navmodules-an-easy-way-to-import-nav-powershell-modules/

2 comments

1 ping

  1. Jakub Vanak

    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…

    1. waldo

      Thanks for the contribution, Jakub!

  1. ArcherPoint Dynamics NAV Developer Digest - vol 149 - Microsoft Dynamics NAV Community

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

Leave a Reply

%d bloggers like this: