Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Microsoft Dynamics NAV Development Quick Start Guide

You're reading from   Microsoft Dynamics NAV Development Quick Start Guide Get up and running with Microsoft Dynamics NAV

Arrow left icon
Product type Paperback
Published in Dec 2018
Publisher Packt
ISBN-13 9781789612769
Length 210 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Alexander Drogin Alexander Drogin
Author Profile Icon Alexander Drogin
Alexander Drogin
Arrow right icon
View More author details
Toc

Table of Contents (10) Chapters Close

Preface 1. Getting Started with the NAV Development Environment FREE CHAPTER 2. Codeunits - Structuring C/AL Code 3. Tables - Creating Data Structure 4. Designing User Interface 5. Exchanging Data with XML Ports 6. NAV Event Model 7. Presenting Data in Reports 8. Debugging Your Code 9. Other Books You May Enjoy

Managing NAV installation with NAV the Administration Shell

The Dynamics NAV Administration Shell is an alternative to MMC. This is a command-line interface that will be familiar to system administrators. Although the graphical interface is easier and more intuitive, the undoubted benefit of the command-line shell is its ability to combine separate commands into complex batch scripts to automate daily administrative tasks.

Creating a NAV Server instance with Administration Shell

To be able to manage NAV server instances, the Administration Shell must be executed with local administrator credentials. In order to do this, select Dynamics NAV Administration Shell in the Windows Start menu, right-click on the application icon, and choose Run as administrator. The Administration Shell will list available commands on startup. NAV Administration Shell is actually a PowerShell command window, and each NAV administration command is a PowerShell cmdlet. With PowerShell functionality, you can get the same list of commands with the Get-Command cmdlet:

Get-Command -Module Microsoft.Dynamics.Nav.Management, Microsoft.Dynamics.Nav.Apps.Management

In the previous section of this chapter, we created a server instance through an MMC snap-in. The same can be done with the New-NavServerInstance cmdlet in the NAV Administration Shell:

New-NAVServerInstance
-ManagementServicesPort 7055
-ClientServicesPort 7056
-SOAPServicesPort 7057
-ODataServicesPort 7058
-
DeveloperServicesPort 7059
-DatabaseServer localhost
-DatabaseInstance NAVDEMO
-DatabaseName "NAV 110 Test Database"
-ServerInstance NavTestServer
-ClientServicesCredentialType Windows

Note that we provide all parameters, including TCP ports and the database name. Unlike the GUI approach, there is no need to modify server settings after creating an instance.

Managing the NAV server with the Administration Shell

Now the brand new service must be started. To start it, run the following command in the Administration Shell:

Start-NAVServerInstance -ServerInstance NavTestServer

The same can be done with a Windows system cmdlet, Start-Service:

Start-Service -Name 'MicrosoftDynamicsNavServer$NavTestServer'

Note that, in this case, we must provide the full-service name, which includes a prefix, MicrosoftDynamicsNavServer$. When we operate with cmdlets developed specifically for NAV Administration Shell, we only provide the NAV server instance name to the command. The actual server name always begins with the same string, which is implicitly added to the parameter by NAV cmdlets. Keep this in mind when you develop your own Powershell code and pass service names between NAV and system cmdlets.

When you no longer need the additional server instance, delete it with the Remove-NAVServerInstance cmdlet:

Remove-NAVServerInstance -ServerInstance NavTestServer

There are some other cmdlets available in the NAV Administration Shell that can simplify your daily administration activities.

If you are already familiar with Windows Powershell, you probably know about a very powerful cmdlet, Get-WmiObject, that can retrieve information about available Windows Management Instrumentation (WMI) classes. For example, with Get-WmiObject, you can list all installed NAV services:

Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -imatch "DynamicsNAV"}

Services will be listed, along with their state and some other properties.

The NAV Administration Shell provides a shortcut for this command. Get-NAVServerInstance will yield the same result, displaying a list of available NAV services.

With the PowerShell pipeline, the resulting list can be filtered. For example, here is the command to select only running services:

Get-WmiObject -Class Win32_Service | Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"}

Or this is the same without the explicit call to Get-WmiObject:

Get-NAVServerInstance | Where-Object {$_.State -eq "Running"}

Now the result set returned by the previous cmdlet can be sent to the pipeline to stop all running services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} | Stop-Service

Now start all stopped services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} | Start-Service

Then restart all running NAV services:

Get-WmiObject -Class Win32_Service | 
Where-Object {$_.Name -imatch "DynamicsNAV" -and $_.State -eq "Running"} |
Restart-Service
You have been reading a chapter from
Microsoft Dynamics NAV Development Quick Start Guide
Published in: Dec 2018
Publisher: Packt
ISBN-13: 9781789612769
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image