---
title: 'Duplicate label names in Microsoft Dynamics AX'
url: 'https://www.kb.hills-family.uk/blog/duplicate-label-names-in-microsoft-dynamics-ax'
markdown: 'https://www.kb.hills-family.uk/blog/duplicate-label-names-in-microsoft-dynamics-ax.md'
date: '2021-05-13'
description: 'Some projects have a lot of labels and when working with a team of developers, merging label files can be a nightmare provide some challenges. Microsoft Dynamics AX doesn’t like duplicate labels and, unfortunately, identifying all instances of duplicates isn’t a straightforward process. I’ve therefore put a PowerShell script together that identifies duplicate labels. The PowerShell sc'
taxonomy:
  tag:
    - 'Dynamics AX'
    - PowerShell
    - 'D365 Finance and Operations'
---

# Duplicate label names in Microsoft Dynamics AX

[ Home ](https://www.kb.hills-family.uk/)     [ Blog ](https://www.kb.hills-family.uk/blog)      Duplicate label names in Microsoft Dynamics AX    

   13 *May*   
#### [Duplicate label names in Microsoft Dynamics AX](https://www.kb.hills-family.uk/blog/duplicate-label-names-in-microsoft-dynamics-ax)

  [Dynamics AX](https://www.kb.hills-family.uk/blog/tag:Dynamics%20AX) [PowerShell](https://www.kb.hills-family.uk/blog/tag:PowerShell) [D365 Finance and Operations](https://www.kb.hills-family.uk/blog/tag:D365%20Finance%20and%20Operations)  

Some projects have a lot of labels and when working with a team of developers, merging label files can be a nightmare provide some challenges. Microsoft Dynamics AX doesn’t like duplicate labels and, unfortunately, identifying all instances of duplicates isn’t a straightforward process. I’ve therefore put a PowerShell script together that identifies duplicate labels.

The PowerShell script will print to screen:

- The duplicate label name
- The corresponding line number of the duplicate entry
- The first instance of the label name

The script is as follows:

```powershell
Function Get-FileName($initialDirectory)
{
    [System.Reflection.Assembly]::LoadWithPartialName("System.windows.forms") | Out-Null

    $OpenFileDialog = New-Object System.Windows.Forms.OpenFileDialog
    $OpenFileDialog.initialDirectory = $initialDirectory
    $OpenFileDialog.filter = "Text files (*.txt)| *.txt"
    $OpenFileDialog.ShowDialog() | Out-Null
    $OpenFileDialog.filename
}

$kwdlist = New-Object System.Collections.Generic.List[System.Object]
$linelist = New-Object System.Collections.Generic.List[System.Object]

$inputfile = Get-FileName pwd

if(!$inputfile) {
    exit
}

$lineno=0
foreach($line in Get-Content $inputfile) {
    $lineno++
    if(!$line.startswith(";") -And $line -like '*=*') {
        $item = $line.split("=")[0]
        if($kwdlist -ccontains $item) {
            $linenumber = $linelist[$kwdlist.indexof($item)]
            Write-Host "Duplicate value '$item' on line $lineno (original on line $linenumber)"
        }else{
            $kwdlist.add($item)
            $linelist.add($lineno)
        }
    }
}
```

Simply save the contents to a file (e.g. `find_duplicates.ps1`) and run the script. A dialog box should pop up asking you to select a label file for processing. Results will appear in the PowerShell window.

 [ Next Post](https://www.kb.hills-family.uk/blog/shrinking-a-linux-virtual-machine-disk-with-vmware) [Previous Post ](https://www.kb.hills-family.uk/blog/generating-multiple-lists-from-a-list-of-tuples)

#### Knowledge Base

Tips, tricks and how-to guides on various topics.

#### Popular Tags

  [Linux](https://www.kb.hills-family.uk/blog/tag:Linux) [Dynamics AX](https://www.kb.hills-family.uk/blog/tag:Dynamics%20AX) [D365 Finance and Operations](https://www.kb.hills-family.uk/blog/tag:D365%20Finance%20and%20Operations) [Network](https://www.kb.hills-family.uk/blog/tag:Network) [Data Management Framework](https://www.kb.hills-family.uk/blog/tag:Data%20Management%20Framework) [Logic Apps](https://www.kb.hills-family.uk/blog/tag:Logic%20Apps) [JavaScript](https://www.kb.hills-family.uk/blog/tag:JavaScript) [netcat](https://www.kb.hills-family.uk/blog/tag:netcat) [SSH](https://www.kb.hills-family.uk/blog/tag:SSH) [PowerShell](https://www.kb.hills-family.uk/blog/tag:PowerShell) [Virtual Machines](https://www.kb.hills-family.uk/blog/tag:Virtual%20Machines) [VMware](https://www.kb.hills-family.uk/blog/tag:VMware) [SQL Server](https://www.kb.hills-family.uk/blog/tag:SQL%20Server) [Wireshark](https://www.kb.hills-family.uk/blog/tag:Wireshark) [Python](https://www.kb.hills-family.uk/blog/tag:Python) [Licensing](https://www.kb.hills-family.uk/blog/tag:Licensing) [Ubuntu](https://www.kb.hills-family.uk/blog/tag:Ubuntu)

---

## Navigation

- Parent: [Blog](https://www.kb.hills-family.uk/blog.md)
- Previous: [Shrinking a Linux Virtual Machine Disk with VMware](https://www.kb.hills-family.uk/blog/shrinking-a-linux-virtual-machine-disk-with-vmware.md)
- Next: [Generating multiple lists from a list of tuples](https://www.kb.hills-family.uk/blog/generating-multiple-lists-from-a-list-of-tuples.md)
