Yesterday I wrote about the new Merging abilities in Cumulative Update 9.
Today I want to take a little time and dive into the 2 first cmdlets: Split-NAVApplicationObjectFile and Join-NAVApplicationObjectFile.
Split-NAVApplicationObjectFile
This cmdlet let you split a text file with NAV objects into individual files. One file for each object.
Let’s first look at the syntax
Split-NAVApplicationObjectFile [-Source] <String> [[-Destination] <String>] [-Force] [-PassThru] [-PreserveFormatting] [-Confirm] [-WhatIf] [<CommonParameters>] |
-Source: | The <String> after the Source points to the source file from which you are reading the NAV Object file you want to split into multiple Object files
An example could be C:\temp\AllObjects.txt |
-Destination: | The <String> after the Destination points to the folder where we want the individual object files written to.
An example could be: c:\temp\Destination\ |
-Force | This is a SwitchParameter that instructs the command to overwrite any existing files in the Destination folder. Generally I would recommend you don’t turn this one on, but make sure you destination folder is empty before using cmdlet. |
-PassThru | The PassThru is another SwitchParameter that instructs the command to return file info for all the files created. Default it will only return a list of files if this SwitchParameter is not set.
The file info includes information such as Mode, Date, Time, Length (File Size in Bytes). |
-PreserveFormating | This is an interesting one. Because the tool knows the object model of Dynamics NAV it reads the object and recreates it based on the object model when it writes it back to the system. This could cause minor changes to happen.
If you want to avoid that you need to set this SwitchParameter which secures the output is exactly the same as the original. |
-Confirm | If set you will get a prompt before the command is run. |
-WhatIf | Interesting one. If set this shows you what would happen if the cmdlet was run, but it is actually not running it. |
-CommonParameters | The CommonParameters are things that are not specific to this cmdlet. I will touch on that later. |
Examples:
Split-NAVApplicationObjectFile -Source C:\temp\AllObjects.txt -Destination C:\temp\Destination\
This does a plain Split of the object into individual files.
Split-NAVApplicationObjectFile -Source C:\temp\AllObjects.txt -Destination C:\temp\Destination\ -PassThru
By adding the PassThru the cmdlet will return file info on all the files it created.
Join- NAVApplicationObjectFile
This cmdlet let you join a set of application objects stored in individual text files into one text file.
What is the syntax:
Join-NAVApplicationObjectFile [-Source] <String> [-Destination] <String> [-Force] [-Confirm] [-WhatIf] [<CommonParameters>] |
-Source: | The <String> after the Source points to the source folder from which you are reading the individual NAV Object files you want to join into a single object file.
An example could be C:\temp\source\ or you can filter it like this C:\temp\source\COD*.TXT |
-Destination: | The <String> after the Destination points to the file you want created containing all the objects you have selected to join.
An example could be:c:\temp\Destination\AllObjects.txt |
-Force | This is a SwitchParameter that instructs the command to overwrite any existing file in the Destination file position. Generally I would recommend you don’t turn this one on, but make sure you destination file has been deleted before using cmdlet, however this if far less dangerous then in the case of the split where you risk having objects files from different solutions mixed in the destination folder. |
-Confirm | If set you will get a prompt before the command is run. |
-WhatIf | Interesting one. If set this shows you what would happen if the cmdlet was run, but it is actually not running it. |
-CommonParameters | The CommonParameters are things that are not specific to this cmdlet. I will touch on that later. |
Examples:
Join-NAVApplicationObjectFile -Source C:\temp\Source\ -Destination C:\temp\All.txt
This will just join the files with the default settings. One interesting think here is that the default setting here is to show the file info while you need to request that with the PassThru SwitchParameter when splitting. There is no possibility to turn that off.
Join-NAVApplicationObjectFile -Source C:\temp\Source\ -Destination C:\temp\All.txt -Force -Verbose
Here we have added Force to ensure we overwrite any existing destination file and we have also added a common parameter called Verbose which outputs information about what is happening as the process is running.
Join-NAVApplicationObjectFile -Source C:\temp\Source\TAB*.TXT -Destination C:\temp\All.txt -Force -Verbose
Here we have added filtering to the Source so we are only reading the Tables from the Source folder.
Common Parameters
I promised to return to Common Parameters and explain, but then I found a great article on technet explaining them all.
http://technet.microsoft.com/en-us/library/hh847884.aspx
This is a great read and I would encourage you all to check it out if you are interested in PowerShell.