Invoke-Application.ps1 using ServiceUI_x64.exe returning exit code [-1] Intermittently

Hi,
My first post on this Community!

I am having an issue with running ServiceUI_x64.exe from Invoke-Application.ps1 via SCCM and it returning an exit code of [-1] Intermittently. When I say Intermittently, I mean that I can click install in the SCCM Software center and it will fail. I can then press retry and it will succeed.

The Invoke.log is showing the following information when failing:

|[Installation] :: [ServiceUI_x64.exe] successfully resolved to fully qualified path [C:\WINDOWS\ccmcache\1w\ServiceUI_x64.exe].|Execute-Process
|[Installation] :: Working Directory is [C:\WINDOWS\ccmcache\1w].|Execute-Process
|[Installation] :: Executing [C:\WINDOWS\ccmcache\1w\ServiceUI_x64.exe -process:explorer.exe Deploy-Application.exe]...|Execute-Process
|[Installation] :: Execution failed with exit code [-1].|Execute-Process

The same Invoke.log when successful is showing the following information:

[Installation] :: [ServiceUI_x64.exe] successfully resolved to fully qualified path [C:\WINDOWS\ccmcache\1w\ServiceUI_x64.exe].	Execute-Process
[Installation] :: Working Directory is [C:\WINDOWS\ccmcache\1w].	Execute-Process
[Installation] :: Executing [C:\WINDOWS\ccmcache\1w\ServiceUI_x64.exe -process:explorer.exe Deploy-Application.exe]...	Execute-Process
[Installation] :: Execution completed successfully with exit code [0].	Execute-Process

The install section from Invoke-Application.ps1: (obviously the first if statement is being run).

  	If ($LoggedonUser -eq $True) {
            Write-Log "A user is logged on. Running Interactive." -Source "COMMENT"
            Execute-Process -Path 'ServiceUI_x64.exe' -Parameters "-process:explorer.exe Deploy-Application.exe"
        }
        Elseif ($runningTaskSequence -eq $True) {
            Write-Log "Installation is running in a Task Sequence. Running Non-Interactive installation." -Source "COMMENT"
            Execute-Process -Path 'Deploy-Application.exe'	-Parameters 'Install'
        }
        Elseif ($LoggedonUser -eq $False) {
            Write-Log "No user is logged on to the machine. Running Non-Interactive installation." -Source "COMMENT"
            Execute-Process -Path 'Deploy-Application.exe' -Parameters 'Install'
        }

I do not know what the issue is as it works Intermittently. What am I doing wrong?!

Thank you

Hi There, I recently experimented with ServiceUI and found it requires a short ~file/~path name to work properly; give that a shot.