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);
Copy your saved .CIL file to c:\script. For example c:\script\saved.cil
Copy the included source code from this KB article into the clipboard
Click Start, All Programs, Accessories, Windows Powershell, “Windows powershell ise”
In Windows PowerShell click in the Untitled1.ps1 window
Paste in contents of the script from this article
Click File, save as, c:\script\ScrubCil.ps1
Click Start, All Programs, Accessories, Windows Powershell, Right click “Windows powershell” and choose “Run as Administrator”
At the powershell prompt type the following commands
cd \script
set-executionpolicy unrestricted
.\ScrubCil.ps1 saved.cil