Creating and Managing Dynamics NAV Web Server Instances Using PowerShell
Applies to: Microsoft Dynamics NAV 2018. See Microsoft Dynamics NAV 2017 version.
Although you can use the Dynamics NAV Setup wizard to install the Microsoft Dynamics NAV Web Server components and create a single web server instance in IIS for the Microsoft Dynamics NAV Web client, there may be scenarios when you want to set up multiple instances. For example, you could set up a separate Microsoft Dynamics NAV Web client instance for the different companies of a business. For this scenario, you can use the Dynamics NAV Web Server PowerShell cmdlets, which are outlined in the following table.
|New-NAVWebServerInstance||Creates a new Dynamics NAV Web Server instance and binds this instance to a Dynamics NAV Server instance.|
|Set-NAVWebServerInstanceConfiguration||Specifies configuration values for a named Dynamics NAV Web Server instance.|
|Get-NAVWebServerInstance||Gets the information about the Dynamics NAV Web Server instances that are registered on a computer.|
|Remove-NAVWebServerInstance||Removes an existing Dynamics NAV Web Server instance.|
Get started with the Dynamics NAV Web Server cmdlets
The Dynamics NAV Web Server cmdlets are contained in the PowerShell script module NAVWebClientManagement.psm1, which is available on the Dynamics NAV installation media (DVD).
The module is installed with the Microsoft Dynamics NAV Server or the Microsoft Dynamics NAV Web Server components.
There are different ways to launch this module and start using the cmdlets:
If you are working on the computer where the Microsoft Dynamics NAV Server was installed, run the Microsoft Dynamics NAV Administration Shell as an administrator.
For more information, see Starting a Microsoft Dynamics NAV Administration Shell Session
If you installed the Microsoft Dynamics NAV Web Server components, just start Windows PowerShell as an administrator.
Otherwise, start Windows PowerShell as an administrator, and use the Import-Module cmdlet to import the NAVWebClientManagement.psm1 file:
Import-Module -Name [filepath]
Import-Module -Name "C:\Program Files\Microsoft Dynamics NAV\110\Service\NAVWebClientManagement.psm1"
For more information about starting Windows PowerShell, see Starting Windows PowerShell.
Creating Dynamics NAV Web Server instances
Get Access to the WebPublish folder
To create a new web server instance, you need access to the WebPublish folder that contains the content files for the Microsoft Dynamics NAV Web client.
This folder is available on the Dynamics NAV installation media (DVD) and has the path "DVD\WebClient\Microsoft Dynamics NAV\110\Web Client\WebPublish".
If you installed the Microsoft Dynamics NAV Web Server components, this folder has the path "C:\Program Files\Microsoft Dynamics NAV\110\Web Client\WebPublish".
You can use either of these locations or you can copy the folder to more convenient location on your computer or network.
Decide on the site deployment type for the instance
When you create a new Dynamics NAV Web Server instance, you can choose to create either a RootSite or SubSite type. Each instance type has a different hierarchical structure in IIS, which influences its configuration and the URLs for the accessing the Microsoft Dynamics NAV Web client.
A RootSite instance is a root-level web site that is complete with content files for serving the Microsoft Dynamics NAV Web client. It is configured with its own set of bindings for accessing the site, such as protocol (http or https) and communication port. The structure in IIS looks like this:
- Sites - DynamicsNAVWebInstance (web site) + nn-NN (language versions) + www (content) navsettings.json ...
The Microsoft Dynamics NAV Web client URL for the RootSite instance has the format:
A SubSite instance is a web application that is under a container web site. The container web site is configured with a set of bindings, but the site itself has no content files. The content files are contained in the application (SubSite). The SubSite inherits the bindings from the container web site. This is the deployment type that is created when you install Microsoft Dynamics NAV Web Server components in the Setup wizard. Using the New-NAVWebServerInstance cmdlet, you can add multiple SubSite instances in the container web site. The structure in IIS for two instances looks like this in IIS:
- Sites - DynamicsNAVWebSite (web site) - DynamicsNAVWebInstance1 (application) + nn-NN (language versions) + www navsettings.json ... - DynamicsNAVWebInstance2 (application) + nn-NN (language versions) + www navsettings.json ...
The Microsoft Dynamics NAV Web client URL of a SubSite instance is generally longer than a RootSite because it also contains the application's alias (or virtual path) for the instance, which you define. The URL for a SubSite instance has the format:
Run the New-NAVWebServerInstance cmdlet
At the command prompt, run the New-NAVWebServerInstance cmdlet. The following are simple examples for creating a RootSite and SubSite deployment type.
New-NAVWebServerInstance -WebServerInstance MyNavWebClient -Server NAVServer -ServerInstance NAVServerInstance -SiteDeploymentType RootSite -WebSitePort 8081 -PublishFolder "C:\Web Client\WebPublish"
New-NAVWebServerInstance -WebServerInstance MyWebApp -Server NAVServer -ServerInstance NAVServerInstance -SiteDeploymentType Subsite -ContainerSiteName MySiteContainer -WebSitePort 8081 -PublisherFolder "C:\WebClient\WebPublish"
Susbtitute MyWebClient with the name that you want to give the web application in IIS for the web server instance. If you are creating a SubSite deployment type, this name will become part of the URL for opening the Microsoft Dynamics NAV Web client application, for example, https://MyWebServer:8081/MyWebApp.
Susbtitute NAVServer to the name of the computer that is running the Microsoft Dynamics NAV Server to which you want to connect.
Susbtitute NAVServerInstance with the name of the Microsoft Dynamics NAV Server instance to use.
Substitute MySiteContainer with name of the container web site under which you want to add the instance. If you specify a name that does not exist, then a new container web site will be created, which contains the new web server instance.
Susbtitute 8081 with the port number that you want to bind the instance to. If you do not specify a port number, then port 80 is used.
Substitute C:\WebClient\WebPublish with the path to your WebPublish folder. By default, the cmdlet looks in the'C:\Program Files\Microsoft Dynamics NAV\110\Web Client' folder. So if you are working on a computer where the Microsoft Dynamics NAV Web Server components are installed, you do not have to set this parameter.
This command only sets the required parameters of the NAVWebServerInstance cmdlet. The cmdlet has several other parameters that can use to configure the web server instance. For more information about the syntax and parameters, see New-NAVWebServerInstance.
Modifying a Dynamics NAV Web Server instance
After you create the web server intance, if you want to change its configuration, you can use the Set-NAVWebServerInstanceConfiguration cmdlet. Or, you can modify the configuration file (navsettings.json) of the instance directly. For more information, see Configuring Microsoft Dynamics NAV Web Client by Modifying the Web.config File.
Deploying the Microsoft Dynamics NAV Web Server Components
How to: Install the Web Server Components
Configuring Microsoft Dynamics NAV Web Client by Modifying the Web.config File