Join and Split Text objects using PowerShell in NAV 2015
Hi,
Microsoft introduce so many new PowerShell Functions and Cmdlets for Development. We can see all list of commands under Microsoft Dynamics NAV 2015 Development Shell. To open development shell click on below icon from start menu or just search for keyword “dev nav” you will see below icon.
Right click on that icon and Run as administrator. It will give full list of PowerShell Functions and Cmdlets. See below screen.
Either we can access it through Default Windows PowerShell ISE. In Start Menu just search for keyword “powershell” you will see below icon.
Right click on that icon and Run as administrator. You will see below screen.
To load Development shell Command into Windows PowerShell ISE just type below command in script area and run it by using Run Script(F5) button, then you will get full list of Functions and Cmdlets which are available in Microsoft.Dynamics.Nav.Model.Tools module.
Import-Module “C:\Program Files (x86)\Microsoft Dynamics NAV\80\RoleTailored Client\Microsoft.Dynamics.Nav.Model.Tools.psd1″ -force
Get-Help “NAV”
Now we will see how to use Join and Split cmdlets.
JOIN
Combines multiple application object files into one text file.
Syntax
Join-NAVApplicationObjectFile [-Source] <String[]> [-Destination] <String> [-Force ] [-Confirm ] [-WhatIf ] [<CommonParameters>]
Description
Use the Join-NAVApplicationObjectFile to combine the application objects in the specified folder into a single text file.
Example
PS C:\>Join-NAVApplicationObjectFile -Source C:\Solution\TXT\COD*.txt -Destination C:\Solution\all-codeunits.txt
This example merges a list of files with application objects, such as COD1.TXT and COD2.TXT, into a single, larger file, all-codeunits.txt. When the merge completes, the status is shown with information about the file that was created.
SPLIT
Splits a text file that contains two or more application objects into separate text files for each application object.
Syntax
Split-NAVApplicationObjectFile [-Source] <String> [[-Destination] <String>] [-Force ] [-PassThru ] [-PreserveFormatting ] [-Confirm ] [-WhatIf ] [<CommonParameters>]
Description
Use the Split-NAVApplicationObjectFile cmdlet to split a text file that contains two or more application objects into separate text files for each application object. For example, if you have exported tables 18 and 27 to a single text file such as MySolution.txt, you can use the cmdlet to create two new text files, TAB18.txt and TAB27.txt.
The Split-NAVApplicationObjectFile cmdlet can copy each application object to a new file, or it can recreate the object in the new file. The default setting is to recreate the object, but you can change this by setting the PreserveFormatting parameter.
Examples
PS C:\>Split-NAVApplicationObjectFile -Source C:\Solution\All.txt -Destination C:\Solution\TXT\
This example creates separate text files for each application object in the All.txt file, such as TAB18.TXT and TAB27.TXT.
PS C:\>Split-NAVApplicationObjectFile -Source C:\Solution\All.txt -Destination C:\Solution\TXT\ -PreserveFormatting
This example creates separate text files for each application object in the All.txt file, such as TAB18.TXT and TAB27.TXT. By setting the PreserveFormatting parameter, each object is an exact copy, including extra line breaks or potential syntax errors. This makes it easier to compare files afterwards, for example.
In NAV 2015 PowerShell cmdlets are very useful and handy for any developer. so you can above cmdlets and save your development time. Now no need to use third-party tools to join and spilt NAV objects text files.
I just love these PowerShell cmdlets. Are you? so start using it…
The post Join and Split Text objects using PowerShell in NAV 2015 appeared first on Jatin Patel - Microsoft Dynamics NAV.

Like
Report




*This post is locked for comments