How to set Port Sharing dependancy to NAV services

I have multiple NAV instances installed on my sandbox development environment. It is very cumbersome to have all nav services in different ports, you have to remember what is this nav version's port number and change it whe you connect the instance. Of course you can use shortcuts that point to specific customsettings.config -files that do it for your behalf, or use some NAV management programs to handle ports.

I have decided to use port sharing. No hassle with port numbers, always standard ports, all you have to do is change the service name and everything works. Nice and simple. For that reason I have been using following command for ages to achieve this goal:

sc config MicrosoftDynamicsNavServer$DynamicsNAV130 depend= NetTcpPortSharing/HTTP

Nowadays I have been more and more to PowerShell, and I decided to convert this simple command into a PS script. The idea being, that you do not need to change the service name rather than let PS get and set it for you automagically.

I came up with following piece of code.

$myNavProcesses =  Get-WmiObject Win32_Service -ComputerName . |`
    where {($_.Name -like "*MicrosoftDynamicsNavServer*")}

if ($myNavProcesses) {
    $myNavProcesses | ForEach-Object {
        $tmpName = $_.Name
        $tmpServiceKey = "HKLM:\SYSTEM\CurrentControlSet\Services\$tmpName"
        write-host $tmpServiceKey
        Set-ItemProperty -Path $tmpServiceKey -Name DependOnService -Value 'NetTcpPortSharing'
    }
}

It is also possible to use WMI object to do the same:

$myNavProcesses =  Get-WmiObject Win32_Service -ComputerName . |`
    where {($_.Name -like "*MicrosoftDynamicsNavServer*")}

if ($myNavProcesses) {
    $DependsOn = 'NetTcpPortSharing'
    $myNavProcesses | ForEach-Object {
        $_.Change($null,$null,$null,$null,$null,$null,$null,$null,$null,$null,$DependsOn)
    }
}

Have fun!

Comment List
Anonymous
  • Run Different dynamics nav version on same port

    1. start NetTcpPortSharing service

    2. Copy server name from services you want to configure on same port

    3. Run CMD as an administrator

    4. write this command "sc config MicrosoftDynamicsNavServer$DynamicsNAV110 depend= NetTcpPortSharing/HTTP"

    5. copy other server name and write this command "sc config MicrosoftDynamicsNavServer depend= NetTcpPortSharing/HTTP"

    6. Restart services and your all servers are running now


    NOTE:

    In your case may be server name can be different so write your servername in this command

    "sc config YourServerName depend= NetTcpPortSharing/HTTP"

Related
Recommended