Options

PowerShell ISE Error on Import Module

jordi79jordi79 Member Posts: 272
When I run the code below:
import-module 'C:\Program Files\Microsoft Dynamics NAV\90\Service\NavAdminTool.ps1'

to import NAVAdminTool.ps1 in PowerShell ISE, I get the following error:
Get-ItemProperty : Cannot find path 'HKLM:\SOFTWARE\Microsoft\Microsoft 
Dynamics NAV\90\Service' because it does not exist.
At C:\Program Files\Microsoft Dynamics NAV\90\Service\NavAdminTool.ps1:12 
char:32
+   $snapInAssembly = Join-Path (Get-ItemProperty -path $nstPath).Path 
"\$snapIn.p ...
+                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (HKLM:\SOFTWARE\... NAV\90\Servi 
   ce:String) [Get-ItemProperty], ItemNotFoundException
    + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetIt 
   emPropertyCommand
 
Join-Path : Cannot bind argument to parameter 'Path' because it is null.
At C:\Program Files\Microsoft Dynamics NAV\90\Service\NavAdminTool.ps1:12 
......

I did not get this error when running the same script in PowerShell. I only get this error when running it in PowerShell ISE.
I have also tried running PowerShell ISE as administrator. I still get the same error.

Answers

  • Options
    postsauravpostsaurav Member Posts: 708
    Hi,
    It seems you have multiple version installed and registry entries are mapped to other version that is installed.
    Do you have multiple NAV Version Installed?

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    jordi79jordi79 Member Posts: 272
    I have. But I have uninstalled previous versions before I installed the latest NAV2016.
  • Options
    yukonyukon Member Posts: 361
    edited 2016-03-23
    Hi,

    You can create the key by manual at Registry. I use below cmdlet for import-module instead of "ps1"
    Import-Module "${env:ProgramFiles}\Microsoft Dynamics NAV\x0\Service\Microsoft.Dynamics.Nav.Management.dll"
    Import-Module "${env:ProgramFiles(x86)}\Microsoft Dynamics NAV\x0\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.dll"
    
    Make Simple & Easy
  • Options
    postsauravpostsaurav Member Posts: 708
    Hi,
    Then if you repair your NAV 2016 installation then Navision Installer will do all Registry Updates.

    Thanks & Regards,
    Saurav Dhyani

    Do you Know this About NAV?


    Connect - Twitter | Facebook | Google + | YouTube

    Follow - Blog | Facebook Page | Google + Page
  • Options
    vaprogvaprog Member Posts: 1,128
    There are x86 and x64 versions of both, the PowerShell console and PowerShell ISE. The x86 versions access the virtualized registry, hiding the x64 parts and mapping the WOW6432Node instead. Therefor they can't see the registry path in question. So, just use the 64-bit versions.
  • Options
    JMAJMA Member Posts: 10
    Thanks vaprog, using the x64 version of powershell ise was the solution
Sign In or Register to comment.