Import-Module "NavAdminTool.ps1" shows wrong version and prevents me from restoring native backup

Slawek_GuzekSlawek_Guzek Member Posts: 1,690
Hi All,

I have a few different NSTs installed side by side on my server. I have installed many version side-by-side by installing base version for each major release, (NAV2016 RTM, NAV2017 RTM, NAV2018 RTM and D365BC RTM) then for cumulatvie updates I have copied the Service folder from the installation image to the appropriate destination (so for example 2018 cu05 went to C:\Program Files\Microsoft Dynamics NAV\110CU05\) and installing the service using sc.exe


Now I am trying to use NavAdminTool.ps1 for NAV2018 CU05 in PowerShell, importing it from the place where the 2018 CU05 is installed and runs from.

I am using command
Import-Module "C:\Program Files\Microsoft Dynamics NAV\110CU05\Service\NavAdminTool.ps1"

However after importing the module PowerShell shows me incorrect version of imported module and commandlets (11.0.19... while it should be 11.0.21836)

ls2nc291z5k8.png

I have checked other binaries in C:\Program Files\Microsoft Dynamics NAV\110CU05\Service\ location and they have correct and expected build numbers:

nq664kruho69.png

What I am doing wrong? What should I do to force correct version of NavAdminTool to be imported?

I have tried so far
Import-Module "C:\Program Files\Microsoft Dynamics NAV\110CU05\Service\NavAdminTool.ps1"
and
CD "C:\Program Files\Microsoft Dynamics NAV\110CU05\Service\"
Import-Module "NavAdminTool.ps1"

Thanks,
Slawek
Slawek Guzek
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03

Comments

  • ftorneroftornero Member Posts: 524
    Hello @Slawek_Guzek ,

    The problem is that even though you import the NavAdminTool.ps1 from the right path, inside there is the line remarked in green that force the path from the register under that key, so you need to change that key to point to the path you want.

    7i39135dl3rw.png

    Regards.
  • nicolassaleronnicolassaleron Member Posts: 11
    edited 2018-12-10
    Hello,

    Actually, NavAdminTool.ps1 is just a script that loads commands from a .Net Assembly and it looks for this assembly in a path declared in the Windows Registry.

    Edit NavAdminTool.ps1 with a text editor and you should find a registry path (ie. : HKLM:\SOFTWARE\Microsoft\Microsoft Dynamics NAV\110\Service)
    Modify the Path according to the installation path of your CU.

    It should work after that

    amssyenr6ug9.png
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Thank you @ftornero and @nicolassaleron

    It only worked when I duplicated the HKLM:\SOFTWARE\Microsoft\Microsoft Dynamics NAV\110\Service" key in he registry and amend the paths in there, or when I changed both $nstPath and $snapInAssembly path definition

    8ilsri5fys4z.png

    It didn't want to work with this alone
    $nstPath = "C:\Program Files\Microsoft Dynamics NAV\110CU05\Service"

    85n77dcrhgdk.png

    I've tried to run first few comands form the script manually and got this
    ce0o56mr8h7k.png

    I can live with the modifiaction of both $nstPath and $snapInAssemblym but I'd be grateful if you help me understand why modification of $nstPath alone didn't work, as from your answers I understood that if should be sufficient
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    @Administrator why I am not able to mark @ftornero and @nicolassaleron answers as Accepted?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • ftorneroftornero Member Posts: 524
    Hello @Slawek_Guzek ,

    If you change the $nstpath to a string, then you need to change the two next lines to reflect that, because there is not an object anymore and have not properties.

    Form this:

    dhcc8z4gdbc8.png

    To this:

    u9n0dsbxps77.png


  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Thank you @ftornero
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
Sign In or Register to comment.