ServerInstance Administration with PowerShell

In Microsoft Dynamics NAV 2017 there a  couple of Cmdlets to administer server instances:

Get-NAVServerInstance
New-NAVServerInstance
Remove-NAVServerInstance
Set-NAVServerInstance

In order to run these Cmdlets we need to start ‘PowerShell ISE’ as an Administrator. Now import the NAV Administration module in order to use the NAV PowerShell Cmdlets.

I will show you how to perform the following tasks:

  • Show current instances
  • Create a new instance
  • Configure your newly created instance
  • Remove your created instance

For these tasks to accomplish you must use the following Cmdlets in your PowerShell ISE like this:

Show all created server instances:

get-navserverinstance

Create a new server instance like this:

New-NAVServerInstance -ServerInstance 'NST2017-Demo' -ManagementServicesPort 7045 -ClientServicesPort 7046 -SOAPServicesPort 7047 -ODataServicesPort 7048

Please note: if you omit a non-mandatory parameter for example ‘SOAPServicesPort’ then SOAP services will be disabled on this Server Instance. The server instance will run under the NETWORK SERVICE account. There are some other parameters to specify more information like:

  • MultiTenant
  • DatabaseServer
  • DatabaseInstance
  • DatabaseName
  • ServiceAccount

There are more parameters but they are used lesser in my opinion. Detailed information about this Cmdlet can be found on MSDN – Developer and IT Pro Help for Microsoft Dynamics NAV.

So one more example. In order to create a server instance that runs under a service account you could use the following Cmdlets:

$ServiceAccountCredential = Get-Credential
New-NAVServerInstance -ServerInstance 'NST2017-Demo' -ManagementServicesPort 7045 -ClientServicesPort 7046 -SOAPServicesPort 7047 -ODataServicesPort 7048 -ServiceAccount User -ServiceAccountCredential $ServiceAccountCredential

This will show the Windows credentials screen where you can enter a username and password. In some cases this is very handy right? In same cases not. So what if you want to hardcode the username and password? This way you don’t have to type in the credentials if you need to create a couple of Server Instances. In order to accomplish we need to create a PSCredential object (New-Object Cmdlet). An example:

$SecurePassword = ConvertTo-SecureString 'YourPassword' -AsPlainText -Force
$ServiceAccountCredential = New-Object System.Management.Automation.PSCredential ("ServiceAccountUsername”, $SecurePassword)
New-NAVServerInstance -ServerInstance 'NST2017-Demo' -ManagementServicesPort 7045 -ClientServicesPort 7046 -SOAPServicesPort 7047 -ODataServicesPort 7048 -ServiceAccount User -ServiceAccountCredential $ServiceAccountCredential


To remove a server instance just type:

$ServerInstance = 'NST2017-Demo'
Remove-NAVServerInstance -ServerInstance $ServerInstance

I like to add the ‘Verbose’ parameter to my Cmdlets. This will output verbose messages and gives more feedback:

verbose-output-in-nav-cmdlets

 

 

Advertisements

Cumulative Update 3 for Microsoft Dynamics NAV 2017 has been released

Microsoft just released Cumulative Update 3. This update includes application and platform hotfixes that have been released for Microsoft Dynamics NAV 2017. This Microsoft Support page shows what has been fixed.

You can download the update from KB 4011763 – Cumulative Update 3 for Microsoft Dynamics NAV 2017 (Build 15140) directly from Microsoft. Now you don’t need an account anymore in order to download the CU. Just select your country in the list for a direct download from the Microsoft Download Center.

Download Microsoft Dynamics NAV 2017

Before you install a cumulative update in a production environment, take the following precautions:

  • First deploy the cumulative update in a non-production environment.
  • Always make a SQL backup in order to have a rollback scenario.

For information about how to install the cumulative update, see How to How to install a Microsoft Dynamics NAV 2017 Cumulative Update