You get an error when you open a list in VAMT 2.0 on a Windows 7-based computer

0 votes
asked Feb 19, 2015 by anonymous

Issue:

When you try to open a list (.cil) in Volume Activation Management Tool (VAMT) 2.0 on a Windows 7-based computer, you may receive the following error message:

“An item with the same key has already been added.”

This problem occurs if there are multiple network adapters in the computer, and these networks adapters have the same MAC address. For example this problem may occur if you have two network adapters for a virtual machine, and you configure these network adapters to have the same MAC address.

If you open the .cil file in this situation, you see an entry that resembles the following:

 

NetworkName="contoso.com" Id="e3f3f83c-f050-4d81-9117-xx">

<MacAddresses>

<MacAddress>00:11:11:CF:FC:xx</MacAddress>

<MacAddress>00:11:11:CF:FC:xx</MacAddress>

</MacAddresses>

Solution:

To work around this issue, manually delete the duplicate entries from the .CIL or to automate this process, use the following source code to create a Powershell script to automate.

 

 

param($inputFilePath, $vamtDirPath)

 

$cilFilePath = Resolve-Path $inputFilePath;

 

if (!$cilFilePath)

 

{

 

  Write-Error "Expected input file name of target CIL";

 

  exit 1;

 

}

 

 

if ($vamtDirPath)

 

{

 

  $vamtDirPath = Resolve-Path $vamtDirPath;

 

}

 

else

 

{

 

  $prograPath = [environment]::GetEnvironmentVariable("ProgramFiles(x86)");

 

 

  if (!$prograPath -or $prograPath -eq "")

 

  {

 

    $prograPath = [environment]::GetEnvironmentVariable("ProgramFiles");

 

  }

 

 

  $vamtDirPath = $prograPath + "\VAMT 2.0"

 

}

 

 

try

 

{

 

  $assembly = [System.Reflection.Assembly]::LoadFile($vamtDirPath + "\Vamtrt.dll");

 

}

 

catch

 

{

 

  Write-Error "Error while attempting to load VAMT assembly. Provide the correct path to your VAMT installation if VAMT is not installed to the default directory.";

 

  exit 1;

 

}

 

 

$fileSerializer = new-object Microsoft.SoftwareLicensing.Vamt.FileSerializer($cilFilePath);

 

 

$softwareLicensingData = $fileSerializer.Deserialize();

 

 

for ($i = 0; $i -lt $softwareLicensingData.Machines.Length; $i++)

 

{

 

  $machine = $softwareLicensingData.Machines[$i];

 

 

  if ($machine.MacAddresses.Count -gt 0)

 

  {

 

    $distinctMacAddrs = new-object System.Collections.ObjectModel.Collection[string];

 

 

    foreach ($mac in $machine.MacAddresses)

 

    {

 

      if (!$distinctMacAddrs.Contains($mac))

 

      {

 

        $distinctMacAddrs.Add($mac);

 

      }

 

    }

 

 

    $machine.MacAddresses.Clear();

 

 

    foreach ($distinctMac in $distinctMacAddrs)

 

    {

 

      $machine.MacAddresses.Add($distinctMac);

 

    }

 

  }

 

}

 

 

$fileSerializer.Serialize($softwareLicensingData);

 

 

 

Then, follow these steps:

 

  1. Copy your saved .CIL file to c:\script. For example c:\script\saved.cil
  2. Copy the included source code from this KB article into the clipboard
  3. Go to Start, All Programs, Accessories, Windows Powershell, "Windows powershell ise"
  4. In Windows PowerShell click in the Untitled1.ps1 window
  5. Paste in contents of the script from this article
  6. Click File, save as, c:\script\ScrubCil.ps1
  7. Go to start Start, All Programs, Accessories, Windows Powershell, Right click "Windows powershell" and choose "Run as Administrator"
  8. At the powershell prompt type the following commands

cd \script

set-executionpolicy unrestricted

.\ScrubCil.ps1 saved.cil

Please log in or register to feedback this question.

Welcome to KnowledgeBase, where you can ask questions and receive answers from other members of the community.
...