Team Blog

The views expressed in this blog are those of the individual and do not necessarily represent those of Microsoft. This information is provided by way of general information only and should not be relied on without obtaining independent expert advice. These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.

Coffee Break 6 - return to piping

This time we will use more piping and other ways to look at a PowerShell object and format it in different ways. For the example here we will use Get-NAVServerInstance and the results from that cmdlet. But everything in this post would apply in the same way on other cmdlets, like

Run the following commands and check how the result differs:Get-NAVServerInstanceGet-NAVServerInstance | Format-TableGet-NAVServerInstance | Format-Table -AutoSize

Select parameters:

Select which columns to return

Get-NAVServerInstance | Select-Object ServerInstance, State

But... How do you know which columns are available? Simply pipe the cmdlet into Get-Member:

Get-NavServerInstance | Get-Member

This shows you a list of members, including these properties

Default DisplayName ServerInstance ServiceAccount State Version

Formatting Output

The most usual formats are list and table. Confusingly to a Dynamics NAV person, Format-List is like a card display, and Format-Table is just like a list. Run these to see the difference:Get-NAVServerInstance | Select-Object ServerInstance, State | Format-ListGet-NAVServerInstance | Select-Object ServerInstance, State | Format-Table

Some of the most useful other formats (to replace the last bit of the pipe above):

This pattern explains how to perform SELECT DISTINCT by using queries in Microsoft Dynamics NAV. It is brought to you by Bogdana Botez from the Dynamics NAV team here at Microsoft Development Center Copenhagen (MDCC).

When you work with tables, sometimes you must perform a SELECT DISTINCT (also known as SELECT UNIQUE) from a table. As Dynamics NAV does not provide this out of the box, we present below a way to select unique records by using queries.

Problem Statement

Let's consider the VAT Entry table:

The goal is to select one line for each separate document that produced VAT Entries. In other words, we want records grouped by Type, Document Type and Document No.. However, if there are multiple lines with the same value of the triad Type, Document Type and Document No. in the VAT Entry table, we only want to see one of them.

Solution

Create a new query object VAT Entry Distinct Document No., with a single DataItem sourced from VAT Entry table. Add the three desired group-by fields Type, Document Type and Document No. as columns.

To enable grouping, add one more column, with Method Type = Totals. This will automatically set the Group By checkbox to TRUE on the three precedent fields.

Note that the Group By field is read-only and trying to set it by hand will clarify that:

Running the query yields a single record per document. You can notice in the second line below for example, how the sales invoice number 103001 had 2 VAT Entries, but it shows up only once in the query:

Example

One thing is to be noted: there is a limitation to how much information you can take out from the records. For example, if we need to extract more information than just the one we already have in the columns, then the following apply: adding one more column of Method Type = None will indeed show more information, but it might affect the grouping. More details below.

This coffee break post illustrates how to search a text file for specific words or a phrase. You can do this with Windows PowerShell in any text files, but let's use some Dynamics NAV objects exported as text. Technically speaking we are reading a text file then piping it line for line through a search cmdlet, which pipes matching lines further to a log.txt file.

Coffee Break 5 - Searching through a Dynamics NAV text file

Customer story:

The developer wants an automated way of locating all occurrences of a string (table name, field name, comment, ...) in a country-specific version of Dynamics NAV, in this example the Norwegian version. And we will log the output of this search to a log file in c:\NAVApp\Log.

Exporting objects from Dynamics NAV:

Prerequisites:

Crete a folder C:\MyNAVApp with a subfolder \Log so that the resulting full path is C:\MyNAVApp\Log.

For this purpose we use the Microsoft Dynamics NAV Application Merge Utilities. Note that these install to the equivalent of C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client. This time we don't need to import the Management module, only the application merge utilities:

Note 1: Make sure to import Microsoft.Dynamics.Nav.Model.Tools.psd1, and not NavModelTools.ps1.

Note 2: This will load the path for finsql.exe too, and use the finsql in the client folder.

Set a few variables. Assuming that we work in folder C:\MyNAVApp\, and we will be searching for where "G/L Account" table reference is used. And we will log the output of this search to a log file in the c:\MyNAVApp\Log folder.

Now load the list of files in the folder. We're using the -File parameter with Get-ChildItem to limit the scope to files only (sub folders are not included).

$myobjects = Get-ChildItem -Path $SourcePath -Filter *txt -File

The next line shows a very simple way to read through all text files in the specified path (c:\MyNAVApp) and for each file searches for the search string (in our case "G/L Account) and for each hit pipe the source line to the log file along with the line number. For this we will use the Select-String cmdlet, that can work directly on Objects with File Info (objects returned by calling Get-ChildItem cmdlet).

Quite a few people have asked that we excavate the guidance for how to upgrade from Microsoft Dynamics NAV 2009 R2 directly to Microsoft Dynamics NAV 2015. We provided this guidance in the blog post for Cumulative Update 1, but as time progresses, this becomes harder to remember and to find. So here you go:

Introduction

Using the upgrade toolkit and conversions tools that are available, the tasks will lead you through the process of converting the Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 database to Microsoft Dynamics NAV 2013, converting the Microsoft Dynamics NAV 2013 database to Microsoft Dynamics NAV 2015, and finally, converting the old data with the old table and field structure to function together with the table and field structure of Microsoft Dynamics NAV 2015.

In order to use the toolkit to upgrade data, you will also need the Microsoft Dynamics NAV 2013 development environment and Microsoft Dynamics NAV 2015.

Data Upgrade Short Overview

The following lists provides a brief description of the steps involved in the data upgrade. The steps are detailed in the task sections that follow.

Make sure that all table objects have compiled successfully.To compile all table objects, in Object Designer, select all objects of type Table, and then on the Tools menu, choose Compile. During compilation, Microsoft Dynamics NAV generates or regenerates the BLOB content in the Object Metadata table that is used in the later steps.

Create a copy or a backup of the Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 database, and open it in the Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 development environment.

Add your Microsoft Dynamics NAV 2015 partner license to the database.You can do this by selecting the Save License in Database field in the Alter Database window. If the field was not already selected, a dialog box opens so you can specify the location of your partner license. If the field was already selected, upload the partner license in the License Information window.

Open Object Designer, and then import Upgrade601800.[Country].1.fob from the \UpgradeToolKit\Local Objects folder. In the Import Worksheet window, choose Replace All, and thenchoose the OK button to import the objects.

In Object Designer, run form 104001, Upgrade - Old Version. Choose the Transfer Data button.

Important: After you have completed this step for all companies, we strongly recommend that you create a full SQL backup the database by using SQL Server management tools.

When you have transferred all data for all companies, in the Upgrade - Old Version window, choose the Delete Objects button.This action deletes all objects in the database that are not tables, but also obsolete tables that belong to functionality that is not available in Microsoft Dynamics NAV 2015.

Run the installation program (setup.exe) for Microsoft Dynamics NAV 2013, choose Choose an installation option, choose Custom, and then choose the Client option (with the Development Environment).

Change the compatibility level of the database according to the following:For SQL Server 2008 R2 set the compatibility level of the database to 100.For SQL Server 2012, set the compatibility level of the database to 110.To do this, you use Microsoft SQL Server Management Studio as follows:

Start Microsoft SQL Server Management Studio and connect to the SQL Server instance that includes the Microsoft Dynamics NAV database.

Right-click the Microsoft Dynamics NAV database, and then select Properties.

In the Database Properties window, choose the Options page, and then set the Compatibility Level to the correct value.

In the Microsoft Dynamics NAV 2013 development environment, open the Microsoft Dynamics NAV 2009 R2 or Microsoft Dynamics NAV 2009 SP1 database and agree to convert the database.During this step, Microsoft Dynamics NAV converts all text and code fields to Unicode format by changing their SQL Server data type. This conversion requires more disk space than usual, since both the database and the log file will grow in size considerably. It can also be a lengthy process.If your Microsoft Dynamics NAV 2009 R2 database is using SQL Server Collation, within the same step the collation will be changed to a suitable Windows collation. This is because Microsoft Dynamics NAV 2013 and higher versions only support Windows Collation.

Important: After the database conversion has completed, we strongly recommend that you create a full SQL backup of the database.

The technical upgrade of the database to Microsoft Dynamics NAV 2013 is complete. You can now uninstall Microsoft Dynamics NAV 2013.

Task 3: Convert the Old Database to a Microsoft Dynamics NAV 2015 Format

Install Microsoft Dynamics NAV 2015.During the installation of Microsoft Dynamics NAV 2015, select the Choose an installation option, then select the Custom option, where you choose to install the Client (with the Development Environment), Server, and Administration Tool components.

To convert the old database to a Microsoft Dynamics NAV 2015 format, open the old database in the Microsoft Dynamics NAV 2015 development environment, and then follow the instructions.

After the database conversion is completed, verify that all system tables are compiled.

System tables have IDs in the range 2000000004 to 2000000130. If any tables are not compiled, then you must compile them. When you compile tables, on the Compile dialog box, set the Synchronize Schema option to Later.

Using Microsoft SQL Server Management studio, add the service account that is used by the Microsoft Dynamics NAV Server instance (for example, NT AUTHORITY\NETWORK SERVICE) as a member of the db_owner role in the Microsoft Dynamics NAV database on SQL Server.For more information, Giving the account necessary database privileges in SQL Server.

Task 5: Run Schema Synchronization to initialize the database.

You can run the schema synchronization from the Microsoft Dynamics NAV Development Environment or Microsoft Dynamics NAV 2015 Administration Shell.

From the development environment:

Open development environment as an administrator.

On the Tools menu, choose Sync. Schema For All Tables, and choose With Validation, and then follow the schema synchronization instructions.

If synchronization errors occur, run the schema synchronization from Microsoft Dynamics NAV 2015 Administration Shell as described in the following procedure. This enables you to get the complete list of tables that could not be synchronized.

From the Microsoft Dynamics NAV 2015 Administration Shell:

Open the Microsoft Dynamics NAV 2015 Administration Shell as an administrator.

Task 6: Import the Application Objects to the Converted Database

In the development environment, import all the application objects that you want in the Microsoft Dynamics NAV 2015 database.When you import the FOB file that contains theMicrosoft Dynamics NAV 2015 objects, on the Import Worksheet, choose Replace All, and then choose the OK buttonto import the objects.On the dialog box for selecting the schema synchronization, set the Synchronize Schema option to Later.

Compile all objects that have not been compiled yet. On the Compile dialog box, set the Synchronize Schema option to Later.

Task 7: Run the Schema Synchronization

Similar to task 5, run the schema synchronization either from the development environment (Tools – Sync. Schema for All Tables – With Validation…) or from Microsoft Dynamics NAV 2015 Administration Shell.

This will synchronize the data schema changes of the newly imported tables to the SQL tables. It will also run the Upgrade Toolkit Step 1 logic if it is defined in the upgrade codeunit. This step will be performed for all companies in the database, so you don’t have to re-run it for other companies.

Note: After the schema synchronization has successfully completed, we strongly recommend that you take a full SQL Server backup of the database.

Task 8: Run the Data Upgrade to perform Upgrade Toolkit Step 2

A data upgrade runs the upgrade toolkit objects, such as upgrade codeunits and upgrade tables, to migrate business data from the old table structure to the new table structure. You can start the data upgrade from the Microsoft Dynamics NAV Development Environment or Microsoft Dynamics NAV 2015 Administration Shell.

From the development environment:

Open development environment as an administrator.

On the Tools menu, choose Data Upgrade, and then choose Start and follow the instructionson the Start Data Upgrade window.

If you want to see the result of running the Data Upgrade action, run the following cmdlet from Microsoft Dynamics NAV 2015 Administration Shell:

In the output of this cmdlet, you can see which upgrade codeunits and functions were run, which companies have been upgraded, the time it took to run each upgrade function, and a detailed description of errors that occurred during the data upgrade.

If errors occurred while running the data upgrade, you can resolve them directly in the database (for example by updating the upgrade codeunits) and then resume the data upgrade. To resume the data upgrade, on the Tools menu, choose Data Upgrade, and then Resume.

Note: To optimize upgrade performance and effectivelyuse the available computerresources, the data upgrade functions are executed in parallel and across all companiesby default. While performing this step, if you discover that some functions are locking each other from executing, then you can configure the data upgrade to execute data upgrade functions in serial instead of parallel. To do this, on the Start Data Upgrade window, set the Execution Mode option to Serial.For more information see http://msdn.microsoft.com/en-us/library/dn762348(v=nav.80).aspx.

From the Microsoft Dynamics NAV 2015 Administration Shell:

Open the Microsoft Dynamics NAV 2015 Administration Shell as an administrator, and then run Start-NavDataUpgrade cmdlet as follows:

Start-NavDataUpgrade -ServerInstance <ServerInstanceName> -Force

Replace <ServerInstanceName> with the name of the Microsoft Dynamics NAV Server instance that is connected to the database.

To view the progress of the data upgrade, you can run Get-NavDataUpgrade cmdlet as follows:

Get-NAVDataUpgrade -ServerInstance <ServerInstanceName> -Progress

Note: The data upgrade process runs CheckPreconditions and Upgrade functions in the upgrade codeunits. If any of the preconditions are not met or an upgrade function fails, you must correct the error and resume the data upgrade process.

Task 9: Delete the Upgrade Objects and Obsolete Tables

At this point, you have upgraded the database to Microsoft Dynamics NAV 2015. Now, you can delete the tables which are not needed into the new application, plus the upgrade codeunits and upgrade table objects that you imported in task 6.

For application tables, you can see which the tables are marked for deletion in the Version List column in the Tables list of Object Designer. During the data upgrade that you performed in task 8, these tables were marked with the text Old Unused Table - marked for deletion. Upgrade objects are marked with the text Upgrade Toolkit Object - marked for deletion.

When you delete tables, if you don’t need the data that is saved in the tables, then on the Delete dialog box, set the Synchronize Schema option to Force.

Task 10: Import upgraded permission sets and permissions by using the Roles and Permissions XMLports

You import the permission sets and permissions XML files according to the following procedure.

To import the permission sets and permissions

Delete all permission sets in the database except the SUPER permission set.In Object Designer, run page 9802 Permission Sets, and then delete the permission sets.

Run XMLport 9171 Import/Export Permission Sets to import the permission sets XML file.In the request page for the XMLport, in the Direction field, choose Import, choose the OK button, and then specify the permission sets XML file.

Run XMLport 9172 Import/Export Permissions to import the permission XML file.In the request page for the XMLport, in the Direction field, choose Import, choose the OK button, and then specify the permissions XML file.

Task 11: Set the Language of the Customer Database

In the development environment, choose Tools, choose Language, and then select the language of the original customer database.

Task 12: Add New Control Add-ins

The database is now fully upgraded and is ready for use. However, you may want to add the new client control add-ins that are included in Microsoft Dynamics NAV 2015. These are not added by the upgrade process. The following client control add-ins are available from the Microsoft Dynamics NAV product media:

Have you been following the coffee break series of blog posts recently? Are you ready to start using Windows PowerShell? If you do not want to get started on your own development database, how about using the Microsoft Dynamics NAV 2015 demonstration database? In this blogpost, we use Windows PowerShell to change the demonstration database into a multitenant environment. Not because we think you should make your own solution multitenant, but because it makes it easier to see what is really going on.

If we look at the Demo Database NAV (8-0) database which is provided on the product DVD (W1), it has one company called CRONUS International Ltd. The first step towards multitenancy is to create additional companies. For this small task we will use the Windows PowerShell ISE. On your Windows machine, you will need to start the Windows PowerShell ISE in an elevated command prompt (Run as Administrator). After that you will need to set the execution policy. You can read more about this here. After that, we will show the cmdlets that are needed and the modules you need to import.

Since we will only run scripts that change the demonstration database, we will run the following command:

Set-ExecutionPolicy unrestricted

After each command, you must press F5. Now choose File in the menu and then select New to open a new screen or simply press CTRL+N. Type in the following command:

NOTE: In a Microsoft Dynamics NAV application that is used in a multitenant deployment, some areas require you to set up web services. Since web services are created in the application database, you must create at least one tenant that has write access to the application database. This setting is determined by the Allow application database writes parameter when you mount a tenant against a Microsoft Dynamics NAV Server instance. For more information, see How to: Mount or Dismount a Tenant on a Microsoft Dynamics Server Instance.

For example, you can create a dedicated administration tenant that you mount against the Microsoft Dynamics NAV Server instance when you create web services for an application. It is also needed allowing to importing FOB files. For more information see this earlier blog post.

Press F5, CTRL+N. Now we will import the example Windows PowerShell scripts that you can find on the Microsoft Dynamics NAV 2015 product media:

NOTE: You can copy the WindowsPowerShellScripts folder from the product media to a safe location on your hard drive as long as you do copy all files in that folder NOTE: If you are running the PowerShell scripts on a computer that does not have SQL Server / SQL Server tools installed, the following tools are necessary: Microsoft® Windows PowerShell Extensions for Microsoft® SQL Server® 2012

Press F5, CTRL+N and we will move the companies from the default tenant to newly created tenants.

To dismount and mount again, I refer you to my previous posting here. You can simply start the Windows client and if you do not change the config files, you will get a message stating that no tenants were specified. Press OK and change the url like this:

NOTE: If you set up multitenancy on a machine that is configured with other releases of Dynamics NAV side by side, it could be that the Administration console may generate an error stating in the PowerShell ISE tool that you can only run the Powershell command lets for a specific release. The root cause could be that you installed Dynamics NAV 2013 R2 after you installed Dynamics NAV 2015 or vice versa. You would need to verify the following key in the registry. It should match the release you are using. V7.1 is the build number for Dynamics NAV 2013 R2 and v8.0 is the build number for Dynamics NAV 2015.

Windows PowerShell can pipe objects. Pipelines are a series of cmdlets (segments) separated by a Pipeline character ‘|’. Each Item is passed through all segments of the pipeline (left to right) before the next is processed.

Piping example:

First import your Dynamics NAV cmdlets (if you are not already in the Microsoft Dynamics NAV Administration Shell, that is):

This imports the NAV.Management.dll for version 80 (=NAV 2015). Adjust the path to the version you are working with.

Get-NAVServerInstance

In case Get-NAVServerInstance returns more than one, then let's filter the one(s) that we want by piping the original result through a filter. Or said in other words: We pipe it to the Where-Object cmdlet:

#Filter by version

Get-NAVServerInstance | where-Object–PropertyVersion-like "8.0*”

One can also omit the –Property parameter here, and just run:

Get-NAVServerInstance | where-ObjectVersion-like "8.0*”

Then we will take the result and pipe that to another cmdlet, let's pipe it to Sync-NAVTenant:

Where $_ is used to reference the Item returned by the previous pipeline segment (in the above example, it references the instance of NavServerInstance Object returned by Get-NAVServerInstance cmdlet). However running the above will still fail to sync Microsoft Dynamics NAV tenants for instances that are not running (State: stopped). This will not abort the process, but we can also further filter on only those instances that are running:

The two pipline segments filtering the output can of course be combined in one. We join the filtering conditions using –And operator. Note that Logical operators (-And / -Or) are valid only within script blocks.

In this post we will run Windows PowerShell in the cloud. The ability to connect your Windows PowerShell with your Microsoft Azure instances can double the value of Microsoft Dynamics NAV and PowerShell, since you now have tools for both on-premises and cloud deployments. And having the choice of hosted deployments is also one of the first prerequisites for moving to Cloud-first as described in the Are you putting the cloud first? article.

Running PowerShell remotely will be handy for customers who migrate or automate their system / part of their system or their development environment in / to the cloud.

Connect

Open your Windows PowerShell ISE. In order to connect to Azure you must have two things:

Azure Publishsettings file which will have all the details of your subscription.

Your Azure account credentials.

#Connect to Azure

import-moduleazure#see pre-requisites from above.

#Check if we are logged on to our Azure subscriuption - expect this to fail for now:

Get-AzureVM

#Log in to your Azure subscription

Add-AzureAccount

Get-AzurePublishSettingsFile #After saving your file once, just skip this point and remember where you save it, you don't need to save it every time. But keep the file safe as it contains connection details.

You should now be able to run generic Azure commands, like Get-AzureVM and Start-AzureVM and more to access your Virtual Machines, and get some of the same information you get via the Azure management portal. Next, we will connect to a running machine and start running PowerShell remotely.

For the next steps you need to have at least one Virtual Machine (VM) running in your Azure subscription. You can create a VM easily from your Azure management portal. You will be able to pick a ready-built image with Microsoft Dynamics NAV 2015 from the Azure marketplace under Microsoft -> Dynamics. You can also create your own VM, and you can still continue with the scripts below.

Note: When you create a new VM, you need to specify both Machine Name and Service Name. Some of the scripts below assume that these two names are the same. So just to avoid any confusion, keep Service Name and Machine Name the same.

To connect to a remote machine we can use the cmdlet New-PSSession. This works nice and easy on your domain. However if the remote machine is in the cloud, connecting becomes a little bit more challenging. Luckily we have helper-scripts, right on the NAV product DVD - for more information, see Deploying and Managing Microsoft Dynamics NAV on Microsoft Azure. In this example, the DVD is in D:\NAVDVD\, and we will import the NAVRemoteAdministration module from the Cloud subfolder.

Before continuing lets just stop and check what the NAVRemoteAdministration module contains:

get-command -moduleNAVRemoteAdministration

What we will use first, is New-NAVAdminSession but also notice functions like Copy-FileToRemoteMachine, Get-NAVServerUserRemotely, New-NAVServerInstanceRemotely and Start-ServiceRemotely. We're sure you can imagine how useful these can be. But first we need to create a session object that we can use to connect: Make sure that the VM you refer to exists and is running, and that service and machine names are the same:

The 4 parameters in this function all are from when you created your VM.

You now have a session variable ($PSSession) that you can use to connect to your cloud VM. This is a persistent session but we will come back to session types in more details another time. You can start either an interactive session or just run scripts to this session.

#Enter an interactive sessionEnter-PSSession$PsSession

get-navserverinstance #will show you any NAV instances on this VM

get-service

dir

and once you are done checking what you want, return to your own PC:

EXIT

Run a script remotely. It is a little bit of a problem to list something, since the result may just stay on the remote machine. So for example Get-NAVServerInstance would run, but not necessarily show you something. So instead we run a cmdlet to run an action - let's stop the Microsoft Dynamics NAV Server service remotely:

The following posting is based on a support request where a partner wanted specific instructions what the process should be when trying to import a FOB file in a true multi tenant environment. If you simply import the FOB file, the following message box will first pop up to you:

This box is new in Dynamics NAV 2015 and is not part of the scope of this blog posting. It is the other message box that needs more explanation:

The first suggestion is to verify if the server is indeed running (of course it is) and the suggestion from support would be to always verify if the server is accessible via the mentioned port. If these are all true, then the second suggestion is to ensure all tenants are dismounted except one. This is because there should only be one tenant mounted that does have the option “Allow application database write to” enabled.

The following configuration will generate the warning “Unable to process table changes because the request cannot be processed by the specified Dynamics NAV Server instance”:

If you dismount all the tenants except the one that does have the option “Allow application database writes” enabled, the warning will not pop up and you will be able to continue the object import. The following configuration will therefore not generate the warning “Unable to process table changes because the request cannot be processed by the specified Dynamics NAV Server instance”:

To dismount a tenant, you can utilize the Microsoft Dynamics NAV 2015 Administration Shell which may need to be start up with Run as Administrator:

In this coffee break we will show a way to deploy Microsoft Dynamics NAV automatically. We assume that Microsoft Dynamics NAV is already installed on the machine, but we want to add additional installations / instances of Microsoft Dynamics NAV.

Coffee Break 2: Automate a Microsoft Dynamics NAV deployment

User Story:The customer has a system where they spin up a new Microsoft Dynamics NAV system every time they - Start a new branch - Start a new series of testing - Start a new Fiscal Year - etcIn practical terms, a "new Microsoft Dynamics NAV system" could mean new Microsoft Dynamics NAV Server instance and database, a new company, or a new tenant. Typically you would end by starting a new Microsoft Dynamics NAV Server service or spinning up a new tenant. For simplicity in this example we just re-use an existing Microsoft Dynamics NAV Server service to start up on our new database.

Pre requisites:We use a SQL Server PowerShell cmdlet: import-module sqlps. SQLPS module is provided with SQL Server installation, but you don't have to install SQL Server to obtain the module.

If you don't have SQL Server installed on the box you're running PS on, you can install Microsoft SQL Server 2012Feature Pack:

Set-ExecutionPolicy unrestrictedimport-module"C:\Program Files\Microsoft Dynamics NAV\80\Service\NavAdminTool.ps1"Push-Location#jump back to standard prompt with pop-locationimport-modulesqlps #ignore any warnings you may get

#At this point the next steps depend on whether we want a new NAV Service, connect to an existing one, etc. Here we just reuse existing NAV Service#Configure then restart the service and get statusSet-NAVServerConfiguration $MyNAVServerName-KeyNameDatabaseName -KeyValue $MyNewDatabaseNameSet-NAVServerInstance$MyNAVServerName -restartGet-NAVServerInstance$MyNAVServerName

The Microsoft Dynamics ERP Translation Solution is now available. This solution was developed by the MBS Engineering International team to improve the experience when Microsoft Dynamics AX and Microsoft Dynamics NAV partners translate our products or the solutions developed by them into existing and additional languages.

The ERP Translation Solution is applicable to Microsoft Dynamics AX 2012 R3 and Microsoft Dynamics NAV 2015 or earlier releases. It provides automation for the translation related tasks through the ERP Translation Tool. Translation is done in the XLIFF format, a localization industry standard format, enabling partners to work with thetranslation editor of their choice. The solution provides automated machine translation and access to MS linguistic assets through the Microsoft Translator Hub from Microsoft Research. Partners are also given the option to use the free light weight translation editor available in the Multilingual App Toolkit (MAT).

Cumulative Update 4 includes all application and platform hotfixes and regulatory features that have been released for Microsoft Dynamics NAV 2015.

The cumulative update includes hotfixes that apply to all countries and hotfixes specific to the following local versions:

AU - Australia

AT - Austria

BE - Belgium

CH – Switzerland

CZ – Czech Republic

DE - Germany

DK - Denmark

ES - Spain

FI - Finland

FR - France

IS - Iceland

IT - Italy

NA - North America

NL - Netherlands

NO - Norway

NZ - New Zealand

RU – Russia

SE - Sweden

UK - United Kingdom

Please note that Cumulative Update 4 requires a database conversion. This is caused by the introduction of the ability to return the Microsoft Dynamics NAV Tablet client as the current client type. You will be able to read about that in the MSDN Library after we complete the monthly update of the Microsoft Dynamics NAV 2015 content there on February 11, 2015. For more information, see Updated Help Content.

We thought that was a good idea. But we also thought we can do even better: Do some NAV PowerShell in your coffee breaks. This post is the first in a series of small script ideas of things you can do with NAV using PowerShell. If you find this useful or have ideas to improvements then please add your comments below and also suggest what you would like to see next.

Coffee Break 1: Add AD users to NAV.

User story

Consider the following scenario: With the new security model in Microsoft Dynamics NAV 2013 and later versions, it is no longer possible to add users and permissions by merely adding Windows Groups. Besides, as of NAV 2013, you may not be using Windows authentication. The user wants to automate what is otherwise a trivial task of looking up Windows users, and entering them into NAV.

The script below will give some ideas for adding NAV users in a batch.

Pre requisites:

Depending on which OS you run it on, you may need to install Remote Server Administration Tools (RSAT). Make sure to install the one that matches your OS and version. If you run Win 8.1 then install it from here:

#AD filter for use in the next line. If you are not on a large domain, then run the next line (get-aduser) without this filter, or if you use the filter then adjust it to your scenario and domain.

$Mysearchbase = "DC=<Domain>[,DC=<Corp Domain>,...]"

#For example:

$Mysearchbase = "DC=EUROPE,DC=CONTOSO,DC=com"

#Next we will get AD users. If you want to import only users from a Windows group or a subdomain, you can filter the result set on sub-domain/group/... Furthermore, we have chosen to retrieve only user name and alias in the example below, but choose any properties that fit your purpose. You can see the entire cmdlet output by running get-help <cmdletname>.Furthermore, we want to save this output into a list that we later can retrieve and modify if needed. The list format and default delimiter might vary depending on regional settings, a semicolon is defined here as a delimiter.

#Another way of assigning the output to a variable is using outvariable. Next we want to then pipe everything to New-NAVServerUser cmdlet to create new users in NAV. In the above example we have only read SamAccountName and User Name from AD, so to add users as Windows users to NAV, following our Contoso scenario, we need to add the domain name too : DOMAIN\samaccountname.

<#Consider now the following scenario. User wants to get AD users using the export script above, but wants to add roles to this user list, before importing them into NAV. So he will break the above process into 2 steps again - in step 1 he will save AD users into a list, then assuming a modified list with added roles - he will import the list of users and their roles into NAV in step 2.

Step one is then unchanged from the example above (using csv list). Next we will assume that the list is now modified to add roles to users.

Example below shows step 2, where this list is imported to create users and assign permissions in NAV. Userlist2.csv file refered to in the script below is the name of the csv file containing users and permissions. Example below shows format of this file (csv, semicolon delimited) with Contoso users as examples:

EUROPE\mrhill;BASIC,RAPIDSTART

EUROPE\mssaddow;BASIC,COST,CASHFLOW

EUROPE\joeroberts;SUPER

If a user or a role defined in this list already exists in NAV, the cmdlet is expected to continue since the ErrorAction parameter is set to Continue (which is also the default value of this parameter). However it is singled out here to direct the attention to error handling opportunities that best fit the user's scenario. Review the possible values of this parameter and how to use them using get-help cmdlet. The following blog is worth checking: