aaronparker / vcredist

Lifecycle management for the Microsoft Visual C++ Redistributables
https://vcredist.com
MIT License
132 stars 17 forks source link

ERROR : Import-VcIntuneApplication : FilePath error #149

Closed Mrbibi38 closed 7 months ago

Mrbibi38 commented 11 months ago

Expected Behavior

Authenticate to a target tenant, retrieve the list of Visual C++ Redistributables for the 2022 version, download the installers to C:\Temp\VcRedist and imports each Redistributable into the target Intune tenant as separate application with the following commands :

Connect-MSIntuneGraph -TenantID contoso.onmicrosoft.com
$Vc = Get-VcList -Export Unsupported | Where-Object { $_.Release -eq "2010" -and $_.Architecture -eq "x86" }
AVERTISSEMENT : This list includes unsupported Visual C++ Redistributables.
$VcList = Save-VcRedist -VcList $Vc -Path C:\Temp\VcRedist
Import-VcIntuneApplication -VcList $VcList

Like explained in the documentation : https://vcredist.com/import-vcintuneapplication/

Current Behavior

I've got the following path error when executing the Import-VcIntuneApplication -VcList $VcList command :

WARNING: Unable to detect expected 'vcredist_x86.exe.intunewin' file after IntuneWinAppUtil.exe invocation
Add-IntuneWin32App: Cannot validate the argument on the parameter 'FilePath'. Unable to bind the argument to the 'Path' parameter because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.494\Public\Import-VcIntuneApplication.ps1:114:47
+             $Application = Add-IntuneWin32App @Win32AppArgs
+                                               ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (:) [Add-IntuneWin32App], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Add-IntuneWin32App

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. Running the initial setup commands :
Set-PSRepository -Name PSGallery -InstallationPolicy Trusted
Install-Module -Name VcRedist, IntuneWin32App
  1. Step execution of the followings commands :
Connect-MSIntuneGraph -TenantID contoso.onmicrosoft.com
$Vc = Get-VcList -Export Unsupported | Where-Object { $_.Release -eq "2010" -and $_.Architecture -eq "x86" }
$VcList = Save-VcRedist -VcList $Vc -Path C:\Temp\VcRedist
Import-VcIntuneApplication -VcList $VcList

Context

ModuleType   Version    Name   
----------------------------------      
Script            4.1.494    VcRedist 

Maybe I miss understand something or failed a command. If anybody can help ;)

eg-RTech commented 11 months ago

Also trying to run the tool and am receiving same error as above. "WARNING: Unable to detect expected 'vc_redist.x86.exe.intunewin' file after IntuneWinAppUtil.exe invocation"

I noticed that when I run the WinAppUtil.exe tool manually it is now omitting the .exe. portion of 'vc_redist.x86.exe.intunewin' and only outputting 'vc_redist.x86.intunewin'

Maybe the file isn't being found because of the name change? Just a thought.

ei-zascha commented 10 months ago

I just noticed there's a Breaking Change discussion that addresses this:

Old syntax

$VcList = Get-VcList
Save-VcRedist -VcList $VcList -Path C:\Temp\VcRedist
Import-VcIntuneApplication -VcList $VcList

New syntax Get-VcList | Save-VcRedist -Path C:\Temp\VcRedist | Import-VcIntuneApplication

So the command you're looking for should be:

Get-VcList -Export Unsupported | Where-Object { $_.Release -eq "2010" -and $_.Architecture -eq "x86" } | Save-VcRedist -Path C:\Temp\VcRedist | Import-VcIntuneApplication

Also, as an alternative workaround you can try adding a Note Property before the Import-VcIntuneApplication command:

$VcList | Add-Member -NotePropertyMembers @{Path="C:\Temp\VcRedist"} -PassThru

With the commands you're using:

Connect-MSIntuneGraph -TenantID contoso.onmicrosoft.com
$Vc = Get-VcList -Export Unsupported | Where-Object { $_.Release -eq "2010" -and $_.Architecture -eq "x86" }
$VcList = Save-VcRedist -VcList $Vc -Path C:\Temp\VcRedist
$VcList | Add-Member -NotePropertyMembers @{Path="C:\Temp\VcRedist"} -PassThru
Import-VcIntuneApplication -VcList $VcList
alexhass commented 8 months ago

@aizascha I have the same issue. I tested in Powershell 5.1 on windows 10 22H2.

$Vc = Get-VcList | Where-Object { $_.Release -eq "2022" }
$VcList = Save-VcRedist -VcList $Vc -Path C:\Temp\VcRedist
$VcList | Add-Member -NotePropertyMembers @{Path="C:\Temp\VcRedist"} -PassThru -force
Import-VcIntuneApplication -VcList $VcList
  1. Add-Member says the attribute already exist. I tried with force.
  2. It still fails with:
Add-IntuneWin32App : Cannot validate argument on parameter 'FilePath'. Cannot bind argument to parameter 'Path' because it is an empty string.
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.495\Public\Import-VcIntuneApplication.ps1:115 char:47
+             $Application = Add-IntuneWin32App @Win32AppArgs
+                                               ~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-IntuneWin32App], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Add-IntuneWin32App

Powershell 7.4.1 tells me:

Import-VcIntuneApplication -VcList $VcList
OperationStopped: C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.495\Public\Import-VcIntuneApplication.ps1:26
Line |
  26 |              throw [System.TypeLoadException]::New($Msg)
     |              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | We can't load the IntuneWin32App module on PowerShell Core. Please use PowerShell 5.1.

How can this defect fixed?

alexhass commented 8 months ago
Get-VcList | Save-VcRedist -Path C:\Temp\VcRedist | Import-VcIntuneApplication
Object does not have valid Path property. Please ensure that output from Save-VcRedist is passed to this function.
At C:\Program Files\WindowsPowerShell\Modules\VcRedist\4.1.495\Public\Import-VcIntuneApplication.ps1:20 char:13
+             throw [System.Management.Automation.PropertyNotFoundExcep ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : RuntimeException