Automate Multiple Web Server Instances for Dynamics NAV Web Client (Part 2)
If you enjoyed (or are still enjoying) creating your Web Clients manually as described in Part 1, it’s time to automate the process!
To achieve this, I wrote a small PowerShell script. The script is self-explanatory and ready to use—or enhance as you see fit.
PowerShell Script: Automate Web Client Instance Creation
# Set-ExecutionPolicy RemoteSigned
mkdir 'C:\Inetpub\wwwroot\MyWebClient'
mkdir 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources'
cmd /c icacls 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources' /grant 'IIS_IUSRS:(OI)(CI)(RX,W)'
copy 'C:\Inetpub\wwwroot\\DynamicsNAV90\web.config' 'C:\Inetpub\wwwroot\MyWebClient\web.config'
Invoke-Expression -Command 'cmd /c mklink /d "C:\Inetpub\wwwroot\MyWebClient\WebClient" "C:\Program Files\Microsoft Dynamics NAV\90\Web Client"'
Import-Module WebAdministration
IIS:New-WebVirtualDirectory -Site 'Microsoft Dynamics NAV 2016 Web Client' -Name 'MyWebClient' -PhysicalPath 'C:\Inetpub\wwwroot\MyWebClient'
ConvertTo-WebApplication -PSPath 'IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient' -ApplicationPool 'Microsoft Dynamics NAV 2016 Web Client Application Pool'
New-Item 'IIS:\Sites\Microsoft Dynamics NAV 2016 Web Client\MyWebClient\WebClient\Resources\ExtractedResources' -type VirtualDirectory -physicalPath 'C:\ProgramData\Microsoft\Microsoft Dynamics NAV\90\Web Client\MyWebClient\WebClient\Resources\ExtractedResources'
Feel free to use or improve this script for your own needs!
Related: Part 1: Manual Setup Guide
How to list “ProcessOnly” Reports in Dynamics NAV 2009
Dynamics NAV Web Client: Filters & FlowFilters on pages
Have questions or suggestions? Reach out via LinkedIn or Twitter.