MSEndpointMgr / IntuneWin32App

Provides a set of functions to manage all aspects of Win32 apps in Microsoft Intune.
MIT License
345 stars 88 forks source link

Error: "Unable to detect expected 'Notepad.exe.intunewin' file after IntuneWinAppUtil.exe invocation" + Fix #121

Open ThomasSteendijk opened 11 months ago

ThomasSteendijk commented 11 months ago

Since this morning (03/11/2023) the creation of intune files seem to have broken using both the current version and old versions of IntuneWin32App.

When using the app to create a intunefile (".intunewin") it fails.

Issue detected on: Version: Live and old versions (1.4.1 + 1.4.0) Computer: Windows 10, windows 11. Clean image. Local machine, Windows VM, Azure VM, Azure devops pipeline

Example:

PS C:\Windows\system32> install-Module -Name "IntuneWin32App"
PS C:\Windows\system32> New-IntuneWin32AppPackage -SourceFolder "C:\Users\TestAdmin\Desktop\TestFolder\Package" -SetupFile Notepad.exe -OutputFolder "C:\Users\TestAdmin\Desktop\TestFolder" -Verbose
VERBOSE: Successfully detected specified source folder: C:\Users\TestAdmin\Desktop\TestFolder\Package
VERBOSE: Successfully detected specified setup file 'Notepad.exe' in source folder
VERBOSE: Successfully detected specified output folder: C:\Users\TestAdmin\Desktop\TestFolder
VERBOSE: Successfully detected IntuneWinAppUtil.exe in: C:\Users\TESTAD~1\AppData\Local\Temp\IntuneWinAppUtil.exe
VERBOSE: Invoking IntuneWinAppUtil.exe to initialize packaging process
VERBOSE: IntuneWinAppUtil.exe packaging process completed with exit code 0
WARNING: Unable to detect expected 'Notepad.exe.intunewin' file after IntuneWinAppUtil.exe invocation

Source of issue: "...\IntuneWin32App\Public\New-IntuneWin32AppPackage.ps1" R:102 "$PackageInvocation = Invoke-Executable -FilePath $IntuneWinAppUtilPath -Arguments "-c ""$($SourceFolder)"" -s ""$($SetupFile)"" -o ""$($OutPutFolder)"" -q""

Invoke-Executable does nolonger seems to work correctly.

Solution: Replace Invoke-Executable with a normal start-process

$PackageInvocation = Start-Process -FilePath $IntuneWinAppUtilPath  -ArgumentList "-c ""$($SourceFolder)"" -s ""$($SetupFile)"" -o ""$($OutputFolder)"" -q"  -PassThru -wait
DanoThom commented 11 months ago

Same issue, confirmed. Good work on the quick PR!

lmartin-ah commented 11 months ago

Can confirm the issue as well. Thanks @ThomasSteendijk

jon-mathias-tandberg commented 11 months ago

Same issue.

MA-Jason-Coombes commented 11 months ago

Same issue

jon-mathias-tandberg commented 11 months ago

The issue is not with IntuneWin32App, but with the new version of IntuneWinAppUtil.exe v1.8.5. invoke-execution.ps1 tries to run the app without the console visible, so we hit this issue: https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool/issues/111. Made a temp workaround to get the old v1.8.4 version and add it to the "$env:temp" path as a workaround until intunewin32apputil.exe is fixed.

jaspain commented 10 months ago

A successful workaround for me with the current IntuneWin32App module v1.4.2 and the current (broken) IntuneWinAppUtil.exe v1.8.5 (file version 6.2312.30.0) is as follows. Modify \PowerShell\Modules\IntuneWin32App\1.4.2\Private\Invoke-Executable.ps1. Change lines 15 - 18 from:

        $ProcessStartInfoObject.CreateNoWindow = $true 
        $ProcessStartInfoObject.UseShellExecute = $false 
        $ProcessStartInfoObject.RedirectStandardOutput = $true 
        $ProcessStartInfoObject.RedirectStandardError = $true 

to

        $ProcessStartInfoObject.CreateNoWindow = $false
        $ProcessStartInfoObject.UseShellExecute = $true
        $ProcessStartInfoObject.RedirectStandardOutput = $false
        $ProcessStartInfoObject.RedirectStandardError = $false

This causes IntuneWinAppUtil.exe to run in a visible command shell window without I/O redirection, but it does run successfully.

See IntuneWinAppUtil.exe cannot be launched from c# code without console visible #111 to track the problem with IntuneWinAppUtil.exe.

jaspain commented 10 months ago

Retracting this workaround for now. While the intunewin files are successfully created, and based on Expand-IntuneWin32AppPackage, they appear to be correct, Intune app creation is failing with the following error messages:

WARNING: Intune service request for operation 'CommitFile' failed
WARNING: Failed to create Win32 app, commit file request operation failed

A successful workaround for me with the current IntuneWin32App module v1.4.2 and the current (broken) IntuneWinAppUtil.exe v1.8.5 (file version 6.2312.30.0) is as follows. Modify \PowerShell\Modules\IntuneWin32App\1.4.2\Private\Invoke-Executable.ps1. Change lines 15 - 18 from:

        $ProcessStartInfoObject.CreateNoWindow = $true 
        $ProcessStartInfoObject.UseShellExecute = $false 
        $ProcessStartInfoObject.RedirectStandardOutput = $true 
        $ProcessStartInfoObject.RedirectStandardError = $true 

to

        $ProcessStartInfoObject.CreateNoWindow = $false
        $ProcessStartInfoObject.UseShellExecute = $true
        $ProcessStartInfoObject.RedirectStandardOutput = $false
        $ProcessStartInfoObject.RedirectStandardError = $false

This causes IntuneWinAppUtil.exe to run in a visible command shell window without I/O redirection, but it does run successfully.

See IntuneWinAppUtil.exe cannot be launched from c# code without console visible #111 to track the problem with IntuneWinAppUtil.exe.

jaspain commented 10 months ago

Same error with the workaround provided by @ThomasSteendijk.

WARNING: Intune service request for operation 'CommitFile' failed
WARNING: Failed to create Win32 app, commit file request operation failed

Speculating that this may be a problem with Microsoft.Graph. Currently using v2.9.1.

jaspain commented 10 months ago

Retested this with different version of various components. Works with PowerShell 7.39, Microsoft.Graph 2.91, IntuneWinAppUtil.exe 1.85, and IntuneWin32App 1.42 with the visible window workaround applied. Fails when PowerShell is upgraded to 7.40 with the 'CommitFIle' error as above. Seems like this is a separate problem. Opened issue Add-IntuneWin32App.ps1 'CommitFile' failed error with PowerShell 7.4.0 #128.

Soolkiki commented 9 months ago

For those automating this through things like Github Runners, I added this Invoke-Webrequest to download the older IntuneWinAppUtil.exe file to the $env:temp directory. That way this module would detect the file I downloaded instead.

Invoke-WebRequest -URI "https://github.com/microsoft/Microsoft-Win32-Content-Prep-Tool/raw/1a00a2a786de646c5fc46d6e1b79988c636e764e/IntuneWinAppUtil.exe" -outfile "$env:TEMP\IntuneWinAppUtil.exe"

$output = New-Item -Path "Remote Desktop" -ItemType "directory" -Name "Output"

New-IntuneWin32AppPackage -SourceFolder "Remote Desktop\Input" -SetupFile "Install-Remote-Desktop.ps1" -OutputFolder $output -Verbose