Skip to content
Dynamics 365 Blog

This post will round up a small series of how to use Windows PowerShell to provision Dynamics NAV in an automated way. In our examples we do this in the cloud, since here we can already automate the machine and OS deployments, but the techniques here will work in any environment. The key element here is “Automation”.

Coffee Break 12 – Provisioning – Automatic installation and deployment of Microsoft Dynamics NAV

Previously we looked at how to use PowerShell to:

  1. Create a Virtual HardDisk (VHD),
  2. Create a Virtual Machine (VM) in the cloud, then
  3. Upload our new VHD to our new VM.

Now, finally we will show how to go ahead an install Dynamics NAV on this new machine. 

Why provision?

There is actually a much easier way to get Dynamics NAV running in the cloud: Use the pre-built Dynamics NAV image in Microsoft Azure. If your Azure subscription is an MSDN subscription, then the Azure marketplace should show a Dynamics category when you create a new VM. This category contains a Dynamics NAV image with a complete, pre-configured Dynamics NAV installation. This image can of course also be provisioned using PowerShell. Here’s a command that looks for pre-built Dynamics NAV images in the Azure marketplace:

Get-AzureVMImage | where { $_.ImageFamily -ilike “*NAV*” } | Sort-ObjectDescending -Property PublishedDate

But as mentioned above, the key word here is “Automation”. So if a ready-built system is not flexible enough, then keep reading.


In this post we will assume that you have already created a new VM and uploaded a Dynamics NAV product DVD to this machine.


The nature of flexibility is that you will need and want to customize this to your exact situation. So the script below will likely need changes, but hopefully it will demonstrate well enough how to complete your automated deployment. The script below is based on the provisioning script on the Dynamics NAV 2013 R2 / Dynamics NAV 2015 product DVD (the folder WindowsPowerShellScripts\Cloud).

Get started with some settings and load the NAVRemoteAdmin module:


$DVDLocationLocal = “C:\NAVDVD”

$DVDLocationRemote = “C:\NAVDVD”

Import-Module $DVDLocationRemote\WindowsPowerShellScripts\Cloud\NAVRemoteAdministration\NAVRemoteAdministration.psm1 

Before we continue take a few moments to run this and see the cmdlets that you now have available from the NAVRemoteAdmin module:

Get-CommandModule NAVRemoteAdministration

Some of these commands are really useful for bridging the gap between your laptop and the cloud and this post will show how much this module helps simplifying remote tasks.

Now we move on and set a few more variables, and then create a PSSession object to access the remote machine.

# Specify the location of your Azure VM

$RemoteMachineAddress = “”
$RemoteMachine = “navnew

$PSSession = New-NAVAdminSessionRemoteMachineAddress $RemoteMachineAddressAzureServiceName $RemoteMachineVMAdminUserName vmadmin –VMAdminPassword HelloWorld2


Configure an installation config file by running Setup from the product DVD, and then in the installation wizard select to save configuration.xml. Here, we have configured and saved an installation config file in 1BoxConfigFile.Xml, overwriting the existing demo file:

# Copy installation config file from local machine to the Azure VM

Copy-FileToRemoteMachineSourceFile $DVDLocationLocal\WindowsPowerShellScripts\Cloud\NAVRemoteAdministrationSamples\1BoxConfigFile.XmlDestinationFile $DVDLocationRemote\1BoxConfigFile.xmlSession $PSSession


In case we need a certificate for Web Client connection:

# Generate a self-signed certificate
$Certificate = Install-SelfSignedCertificateRemotelySubjectName $RemoteMachineAddressStoreScope ‘LocalMachine’ -StoreName ‘My’ -RemoteDirectoryc:\Cert”Session $PSSession


# Or import a signed certificate
# [System.Security.SecureString]$CertificatePfxPasswordAsSecureString = ConvertTo-SecureString $CertificatePfxPassword -AsPlainText -Force


$WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotely
$WebServerSSLCertificateThumbprint = Get-CertificateThumbprintCertificate $Certificate
$Certificate = Import-PfxFileRemotely `
                                –PfxFile $CertificatePfxFilePath `
                                -PfxPassword $CertificatePfxPasswordAsSecureString `
                                -Session $MySession                               

# Get installed certificate thumbprint
$WebServerSSLCertificateThumbprint = Get-CertificateByThumbprintRemotelyCertificate $CertificateSession $PSSession


Install the .NET Framework if needed

Ideally, make sure that the VM you provisioned already has the required version of .NET Framework (4.5). Or if needed you can automate it – look in the provisioning script on the Dynamics NAV 2015 product DVD in WindowsPowerShellScripts\Cloud\NAVRemoteAdministrationSamples\Install-DotNETRemotely.ps1 how to install it and restart the VM remotely if needed.


Install Dynamics NAV

# Install prerequisites on VM      
$DVDLocationRemote = “C:\NAVDVD”
Install-NAVPrerequisitesRemotelyRemoteNavDvdLocation $RemoteNavDvdLocationSession $PSSession | Out-Null

# Install NAV components from dvd copied to VM
Install-NAVComponentRemotely –RemoteDVDPath $DVDLocationRemote RemoteConfigurationFilePath $DVDLocationRemote\1BoxConfigFile.xml –Session $PSSession


Additional (optional) settings and finishing off

# Remove the default IIS web site to free port 80 for the NAV Web Client
Remove-DefaultWebSiteRemotelySession $PSSession  

#Start the web site   
Start-NAVWebClientRemotelySession $PSSession

#Open Azure endpoint for the Web Client. We assume the web client will always occupy port 443.
$RemoteMachine = “navnew
$RemoteServiceName = “navnew
Get-AzureVMName $RemoteMachineServiceName $RemoteServiceName | Add-AzureEndpointName “NAV_Web_Client” –Protocol “tcp” -LocalPort 443 -PublicPort 443 | Update-AzureVM | Out-Null


This was an example of how to install Dynamics NAV on one machine. Watch out for future posts on how to automate deployment on multiple machines. Example scenario: Automating Cumulative Update deployment.



Jasminka Thunes, Escalation Engineer Dynamics NAV EMEA

Lars Lohndorf-Larsen, Escalation Engineer Dynamics NAV EMEA

Bas Graaf, Senior Software Engineer Dynamics NAV


We're always looking for feedback and would like to hear from you. Please head to the Dynamics 365 Community to start a discussion, ask questions, and tell us what you think!