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:
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:
This was real help full cheers M8 :-)
LikeLike