none
ScanErrorException when using Poweshell MetadataExchange RRS feed

  • Question

  • Hello,

    I have been trying to use the PowerShell module MetadataExchange on Windows 10 without luck.

    I am setting up new build machines which need to run a PowerShell script using the MetadataExchange module. This script is used to generate an EMX file to be used later on. Previous machines have been working fine, but none of the new ones. The previous ones are on Windows 7 when the new ones are on Windows 10.

    The script being run is:

    [CmdletBinding()]
    Param(
      [Parameter(Mandatory=$False,Position=0)]
       [string]$path="ProductName-126709.dll",
    	
       [Parameter(Mandatory=$False,Position=1)]
       [string]$product="ProductName",
    
       [Parameter(Mandatory=$False,Position=2)]
       [string]$version="1.0",
    
       [Parameter(Mandatory=$False,Position=3)]
       [string]$output="out.emx"
    )
    
    if ($env:PROCESSOR_ARCHITEW6432 -eq "AMD64") {
        if ($myInvocation.Line) {
            &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile $myInvocation.Line
        }else{
            &"$env:WINDIR\sysnative\windowspowershell\v1.0\powershell.exe" -NonInteractive -NoProfile -file "$($myInvocation.InvocationName)" $args
        }
    exit $lastexitcode
    }
    
    Import-Module -Name MetadataExchange
    
    $dirPath = $path
    $productName = $product
    $productVersion = $version
    $outputFile = $output
    
    $dirFiles = Get-ChildItem -Path $dirPath -Include @("*.dll","*.vst3") -rec   
    
    Write-Host "folder list : $dirFiles"
    
    Clear-Metadata
    
    Write-Host "Clearing MEtadata"
    
    Write-Host "New Product -Name $productName -Version $version -Lifecycle CurrentRelease "
    $productName = New-Product -Name "$productName" -Version "$version" -Lifecycle CurrentRelease 
    
    Write-Host "Add Product"
    Add-Product -Product $productName
    
    foreach($file in $dirFiles)
    {
        Write-Host "New-ProductFile $file.FullName | add-ProductFile $productName"
        Write-Host "$file.FullName "
        
        New-ProductFile $file.FullName | add-ProductFile $productName
    
    }
    
    
    Export-MetaData  $outputFile
    
    return $outputFile
    

    I have installed WindowsLive Essentials with Messenger (this is required by the module), then installed the MetadataExchange module for PowerShell.

    I have changed the execution policy to "Unrestricted" for both CurrentUser and LocalMachine.

    When I run the script and give it a valid DLL (which worked in the past) the script fails executing "New-Product" and display the error:

    New-ProductFile : Unknown error. Check the event log for more details.
    At D:\PowerShellMetadataTest\CreateEmx.ps1:56 char:5
    +     New-ProductFile $file.FullName | add-ProductFile $productName
    +     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [New-ProductFile], ScanErrorException
        + FullyQualifiedErrorId : Microsoft.Telemetry.MetadataExchange.ScanErrorException,Microsoft.Telemetry.MetadataExchange.Commands.NewProductFileCommand

    On some machines it works if it's run with an elevated PowerShell Windows but not on normal privileges. On some other machines it doesn't work at all. It looks to me like it's a permission issue to execute the DLL from the module or to read the file, but I can't figure why.
    I have checked the module DLL permissions, the files permissions, and the main user is administrator. What am I missing?

    This is the module content:

    Mode                LastWriteTime     Length Name
    ----                -------------     ------ ----
    d----        12/15/2017   3:07 PM            en-us
    -a---         5/23/2013   8:10 AM      14122 MetadataExchange.ps1xml
    -a---         5/23/2013   8:10 AM      20356 MetadataExchange.psd1
    -a---         5/23/2013   8:10 AM      31384 Microsoft.Telemetry.Authentication.dll
    -a---         5/23/2013   8:10 AM      54424 Microsoft.Telemetry.Core.dll
    -a---         5/23/2013   8:10 AM      38552 Microsoft.Telemetry.MetadataExchange.Cmdlets.dl
    -a---         5/23/2013   8:10 AM     170136 Microsoft.Telemetry.MetadataExchange.Core.dl

    Also as a side question, this module is very old (which might be the problem on Windows 10), you can't even find the WindowsEssential installer on Microsoft website anymore; is there a replacement solution for that with a more modern technology? Basically we are trying to get information from Microsoft server whenever our DLL crashes so we can get the crash reports.

    Kind regards,
    Maxime

    • Moved by Hart Wang Tuesday, December 19, 2017 6:04 AM
    Friday, December 15, 2017 2:20 AM

All replies