«

»

Print this Post

Load Dynamics NAV CmdLets in PowerShell ISE with Profiles

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

I think we can all agree that we like the Windows PowerShell ISE, right? You know, the “C/SIDE for PowerShell” ;-), the editor, this one:


And the one thing that is somewhat less convenient, is the fact that you always have to load the NAV CmdLets into your runspace by typing these lines:

During the NAVTechDays Pre-Conference workshop, someone (forgot his name – sorry :() pointed out to me that it was possible to add this in the “Profile”, so that it gets loaded every time you start the ISE.

Huh, profile?

That was my first reaction. :-). Now, it’s actually quite simple. All you need to do is create a file following these guidelines: How to Use Profiles in Windows PowerShell ISE

So .. we would like all the users to benefit from our new addition in the profile, so Start the ISE as an Administrator, and execute this:

It will create the profile-file if it didn’t exist yet, and open it in the ISE editor, ready for you to add some code. Now, before we start adding code .. let’s first see what I would like to create:


An extra menu-item the you can click to load the NAV2015 CmdLets (and accordingly, you can add menu-items for multiple versions if you like). Well, your profile-file is open. Add this code in it:

 

You see it’s quite simple: we put a codeblock with code into a variable, and we add a menu-item in the ISE, that executes this codeblock. As simple as that!

Now, because your profile will always be loaded, it will create a menuitem with exactly that code every time you open the ISE. Just click, and your favorite CmdLets will be loaded into the runspace!

Enjoy!

Ps: I actually just showed you an easy way to make available your scripts. I have added a lot more in this profile, loading my “changed” (read: fixed) NAV Commandlets and such, so they are always available in my environment.

Permanent link to this article: http://www.waldo.be/2015/07/20/load-dynamics-nav-cmdlets-in-powershell-ise-with-profiles/

3 comments

3 pings

    1. waldo

      Yup, now I remember :-). Thanks! (Shame on me … he even sent me this..)

  1. Sebastian

    Just as small note, if you want to remove an older or wrong entry try this one:

    $MyEntry = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus | ?{$_.DisplayName -eq “Load NAV 2015 CmdLets”}
    $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Remove($MyEntry)

  1. Load Dynamics NAV CmdLets in PowerShell ISE with Profiles | Pardaan.com

    […] Bron : Waldo’s Blog Lees meer… […]

  2. Load Dynamics NAV CmdLets in PowerShell ISE with Profiles | Vacuum

    […] Via Eric Wauters […]

Leave a Reply

%d bloggers like this: