At times some apps fail, need to be deleted and reinstalled, but Intune is a bit notorious on waiting for full app inventory refreshes As I recall, it's only once every 7 days. So I have uninstalled half a dozen apps from a test machine and Intune will show them as installed until the next cycle comes (in the Discovered Apps blade).

If someone happens to know how to force a refresh for this list from the client side, do please let me know.

What I had issues with on some devices was the Company Portal app. This supposed to install quite soon after Autopilot enrollment, or even during, since it is a device targeted app.

When it fails however, or is installed on the device but won't appear for the user, this script nukes all residues, clear the IME registry entries, removes GRS (read more on it on Rudy's blog) information and allows the Company Portal to come back clean in less than 15 minutes according to my tests.

In theory it can be re-used for other apps, but this removes Company Portal as an AppxPackage, so make sure you change the uninstall method for your other app as well and add its AppId on line 2.

Running this on a healthy system (as a remediation script in Intune for example) should see the Company Portal disappear for a few mins and the come back refreshed and ready to be used again.

Hope it's helpful for some.

EDIT: In fact, I might have just recreated Rudy's solution to the same problem. As they say in Croatia - od viska glava ne boli - which roughy translates to “From surplus, your head doesn’t hurt.” 😄

# Insert your Company Portal App ID here from Intune
$CompanyPortalAppID = '12345678-1234-1234-1234-12345678'

# Delete the AppxPackage for Company portal for all users from the running system
Write-Host "Uninstalling Company Portal for all users with Remove-AppxPackage cmdlet..." -ForegroundColor Green
Get-AppxPackage -AllUsers | ? {$_.name -match "Microsoft.CompanyPortal"} | Remove-AppxPackage -AllUsers

# Remove the registry keys and sub keys
Write-Host "Checking under IntuneManagementExtension\Win32Apps\Reporting..." -ForegroundColor Yellow
if (get-item -path "hklm:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\Reporting\00000000-0000-0000-0000-000000000000\$CompanyPortalAppID"){
    Write-Host "Removing keys under IntuneManagementExtension\Win32Apps\Reporting..." -ForegroundColor Green
    Remove-Item -Path "hklm:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\Reporting\00000000-0000-0000-0000-000000000000\$CompanyPortalAppID" -Force -Recurse    
}

Write-Host "Checking under IntuneManagementExtension\Win32Apps\Reporting\AppAuthority..." -ForegroundColor Yellow
if (Get-ItemProperty -Path "hklm:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\Reporting\AppAuthority" -Name $CompanyPortalAppID){
    Write-Host "Removing keys under IntuneManagementExtension\Win32Apps\Reporting\AppAuthority..." -ForegroundColor Green
    Remove-ItemProperty -Path "hklm:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\Reporting\AppAuthority" -Name $CompanyPortalAppID
}

Write-Host "Checking under IntuneManagementExtension\SideCarPolicies\StatusServiceReports..." -ForegroundColor Yellow
if (resolve-path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\SideCarPolicies\StatusServiceReports\*\$CompanyPortalAppID"){
    Write-Host "Removing keys under IntuneManagementExtension\SideCarPolicies\StatusServiceReports..." -ForegroundColor Green
    Remove-Item -Path  $(resolve-path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\SideCarPolicies\StatusServiceReports\*\$CompanyPortalAppID") -Recurse -Force
}

Write-Host "Checking under IntuneManagementExtension\Win32Apps\..." -ForegroundColor Yellow
if (resolve-path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\*\*" | ? {$_.Path -match "$CompanyPortalAppID"}){
    Write-Host "Removing keys under IntuneManagementExtension\Win32Apps\..." -ForegroundColor Green
    Remove-Item -Path $(resolve-path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\*\*" | ? {$_.Path -match "$CompanyPortalAppID"}) -Recurse -Force
}

Write-Host "Checking under IntuneManagementExtension\Win32Apps\Operational State..." -ForegroundColor Yellow
if (test-path -path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\OperationalState\00000000-0000-0000-0000-000000000000\$CompanyPortalAppID" | ? {$_.Path -match "$CompanyPortalAppID"}){
    Write-Host "Removing keys under IntuneManagementExtension\Win32Apps\OperationalState..." -ForegroundColor Green
    Remove-Item -Path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\OperationalState\00000000-0000-0000-0000-000000000000\$CompanyPortalAppID" -Recurse -Force
}

Write-Host "Getting GRS keys..." -ForegroundColor Yellow
$GRS=resolve-path "HKLM:\SOFTWARE\Microsoft\IntuneManagementExtension\Win32Apps\*\GRS\*\"
$GRS=Get-Random -InputObject $GRS -Count $GRS.count
Write-Host "Searching for Company Portal in GRS keys..." -ForegroundColor Yellow
foreach ($Key in $GRS) {
        if (Get-ItemProperty -Path "$key" -Name $CompanyPortalAppID -ErrorAction Ignore){
        Write-Host "Removing Company Portal key from GRS..." -ForegroundColor green
        remove-item $key -Recurse -Force
        break
    }
}

# restart service and delete the logs to start from fresh
Start-Sleep -Seconds 5
Write-Host "Stopping IME Service..." -ForegroundColor Cyan
Stop-Service -name IntuneManagementExtension
Start-Sleep -Seconds 5
Get-ChildItem -Path C:\ProgramData\Microsoft\IntuneManagementExtension\Logs | ? {$_.Name -match '.log'} | Remove-Item -Force -ErrorAction SilentlyContinue
Start-Sleep -Seconds 5
Write-Host "Starting IME Service..." -ForegroundColor Cyan
Start-Service -name IntuneManagementExtension
Write-Host "`nFinished!" -ForegroundColor White

Force Company Portal app repair/reinstall by Intune Management Extension