Powershell ISE and multiple NAV-versions: Where to define which NAV-version ISE should use?

MariaNAVMariaNAV Member Posts: 5
Hello All

I am working on a small Powershell script that will run a NAV codeunit. I recently installed NAV2016 (9.0) as a test before our upgrade sometime next year (we are now running NAV2013r2 (7.1)), so I have two versions running.

Powershell ISE automatically runs the 9.0 version (apparantly because that is the most recently installed?), but I want it to automatically run the 7.1 version.

So my question is: Where is the setting where you which NAV-version it uses as standard? Or alternatively: Can I define somewhere in a script that it should use one version instead of the other?

I have found a workaround, which is easy but not optimal: If I just take the "71" folder in "C:\Program Files (x86)\Microsoft Dynamics NAV" and rename it to"90", the PowerShell ISE program will run the exe-file in 90-folder, althorugh it contains the 71-version. But I whould much rather that the program just started NAV-version in the 71 folder.

Thank you so much in advance.

Regards,

Maria

Best Answer

Answers

  • PoltergeistPoltergeist Member Posts: 200
    Doesn't Import-Module '%programfiles%\Microsoft Dynamics NAV\71\Service\NavAdminTool.ps1 do the job?
  • MariaNAVMariaNAV Member Posts: 5
    Thank you for the reply.

    No, if I use Import-Module 'C:\Program Files\Microsoft Dynamics NAV\71\Service\NavAdminTool.ps1' it will stil try to run the exe-file in the 90-folder, so the imported NavAdminTool-file does not influence which folder the subsequent powershell script uses.

    FYI, I am following Waldo's guide to running af codeunit from Powershell (http://www.waldo.be/2015/07/09/start-nav-object-in-rtc-with-powershell/), and this is my code
    
    Import-Module 'C:\Program Files\Microsoft Dynamics NAV\71\Service\NavAdminTool.ps1'
    
    function Start-NAVApplicationObjectInWindowsClient
    {
        [cmdletbinding()]
        param(
            [string]$ServerName=[net.dns]::Gethostname(), 
            [int]$Port=6411, 
            [String]$ServerInstance, 
            [String]$Companyname, 
            [string]$Tenant='default',
            [ValidateSet('Table','Page','Report','Codeunit','Query','XMLPort')]
            [String]$ObjectType,
            [int]$ObjectID
             )
    
        $ConnectionString = "DynamicsNAV://$Servername" + ":$Port/$ServerInstance/$Companyname/Run$ObjectType"+"?$ObjectType=$ObjectID&tenant=$tenant"
        Write-Verbose "Connectionstring: $ConnectionString ..."
        Start-Process $ConnectionString
    }
    
    Start-NAVApplicationObjectInWindowsClient -ServerName ([net.dns]::GetHostName()) -ServerInstance MyService-Tenant MyTennat-ObjectType Codeunit -ObjectID 6169471
    
    
    
  • mohana_cse06mohana_cse06 Member Posts: 5,504
    Answer ✓
    Open RegEdit from Commandprompt
    select HKEY_LOCAL_MACHINE\SOFTWARE\Classes\DYNAMICSNAV\Shell\Open\Command

    Change path from 90 to 71...
  • MariaNAVMariaNAV Member Posts: 5
    mohana_cse06 answered the question, thank you! That works perfectly.

    Thank you again :)
Sign In or Register to comment.