It’s always the simple things that turn out to be more complicated than expected. I was deploying new machines with Windows 11 and needed to automate the process of adding PowerShell 7.4 and .NET 8 to them. That should be simple enough, I can just use Winget to install them. But there was one problem: Winget was broken, so it failed to install anything. And you can’t update Winget with Winget when Winget is broken, for obvious reasons.

I figured that there had to be a simple, automated way to update Winget, which is part of the Desktop App Installer app available on the Microsoft Store. There are WinRT APIs available to do this (as UWP apps might need to trigger the installation or updating of themselves or other apps), but how do you call those from PowerShell? That’s the hard part: pretty much everything in WinRT uses async methods, many using generic types, which makes the PowerShell logic rather complicated. Eventually I found a thread on Github that explained how to do it, with working example: https://github.com/microsoft/winget-cli/discussions/1738

So after a little cleanup and testing, I published a version of that to the PowerShell Gallery as Update-InboxApp. You can install it and run it to update a single app, like this:

Install-Script Update-InboxApp
Update-InboxApp "Microsoft.DesktopAppInstaller_8wekyb3d8bbwe"

Or you call try to update all the apps at once:

Install-Script Update-InboxApp
Get-AppxPackage | Update-InboxApp

It’s worth noting that some of the in-box apps aren’t actually updated from the Microsoft Store, so you’ll see a bunch of warnings related to that:

That’s OK, just be aware that some app updates need to be installed through other means, e.g. Windows Update. Also, these WinRT APIs can only be called from the .NET Framework, not .NET Core, so this will only work with PowerShell 5.1; don’t try newer versions. (I suspect there’s a way to fix this, but haven’t had time to look into that yet.)

Overall, the script ends up working pretty well to solve the original problem, and has use cases beyond that as well. But of course after doing that, I then came across another solution to the same problem, specifically around updating Winget. Andrew Taylor posted a blog about that back in December that uses the Repair-WingetPackageManager cmdlet to achieve the same result. The basic process for that:

Install-Module microsoft.winget.client -Force -AllowClobber
Import-Module microsoft.winget.client
repair-wingetpackagemanager

Behind the scenes, that Repair-WingetPackageManager cmdlet will download the latest Winget bits from Github, so it has no dependency on using Winget to update Winget. So take your pick on the approach, but at the very least be aware of the challenge when using Winget (either directly or indirectly — note that Intune uses Winget for installing store apps when you are using the “Microsoft Store app (new)” application type).


Discover more from Out of Office Hours

Subscribe to get the latest posts sent to your email.

7 responses to “Updating in-box apps with PowerShell”

  1. This query works much better for you:

    Get-AppxPackage | Where { $_.NonRemovable -eq $false -and $_.IsFramework -eq $false } | Update-InboxApp

    Like

  2. Im a big fan of the Repair-WingetPackageManager command but it doesn’t work properly when run as system. It returns Winget healthy even if it’s not present. I filed a bug report. Works great as an elevated admin so works well in MDT TS as a good way to make sure it’s updated before running Winget installs in OSD.

    Liked by 1 person

  3. Hi, I am using this to update my inbox apps but I am getting an error message. This is error message is not showing in all the machines but in few of them (1:10). The error message is:

    PS>TerminatingError():”Exception calling”Wait”with”1″argument(s):”one or more errors occured.””
    WARNING:Error updating app Microsoft.Microsoft3DViewer_8wekyb3d8bbwe:
    System.Exception:Exception from HRESULT:0x080248014

    Like

    1. Are you specifying that app name explicitly? I don’t believe that app is installed by default in Windows 11 any more, so perhaps it isn’t there?

      Like

      1. Oh! my bad, this error is actually showing for all the inbox applications which iterating through for each loop inside the UpdateAppByPackageFamilyNameAsync() by default. I am running it on the Windows 10 machines having 22H2. It is working on most of the machines but few of them throwing this error.

        Like

  4. Erros while running the above given commands in PowerShell as Admin(Error is limited to only few of windows 10, 22H2 Machines):

    PS C:WINDOWSsystem32> Get-AppPackage | Update-InboxApp.ps1
    WARNING: Error updating app Microsoft.BioEnrollment_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Excepti
    on from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.CloudExperienceHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (
    503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.AAD.BrokerPlugin_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exce
    ption from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.OOBENetworkConnectionFlow_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavail
    able (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.OOBENetworkCaptivePortal_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavaila
    ble (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app MicrosoftWindows.Client.CBS_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exc
    eption from HRESULT: 0x801901F7)
    WARNING: Error updating app MicrosoftWindows.UndockedDevKit_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503).
    (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.StartMenuExperienceHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailab
    le (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.ShellExperienceHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (
    503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app windows.immersivecontrolpanel_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (E
    xception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.549981C3F5F10_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Excepti
    on from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.VCLibs.140.00.UWPDesktop_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503
    ). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.NET.Native.Framework.2.2_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503
    ). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.NET.Native.Runtime.2.2_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503).
    (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.Search_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Except
    ion from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MicrosoftEdge.Stable_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (
    Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.ContentDeliveryManager_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailabl
    e (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.VCLibs.140.00_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Excepti
    on from HRESULT: 0x801901F7)
    WARNING: Error updating app 1527c705-839a-4832-9118-54d4Bd6a0c89_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (5
    03). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app c5e2524a-ea46-4f67-841f-6a9465d9d515_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (5
    03). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app E2A4F912-2574-4A75-9BB0-0D023378592B_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (5
    03). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app F46D4000-FD22-4DB4-AC8E-4E1DDDE828FE_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (5
    03). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.AccountsControl_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Excep
    tion from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.AsyncTextService_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exce
    ption from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.CredDialogHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Except
    ion from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.ECApp_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception from
    HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.LockApp_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception fro
    m HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MicrosoftEdgeDevToolsClient_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (
    503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Win32WebViewHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exce
    ption from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.Apprep.ChxApp_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503).
    (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.AssignedAccessLockApp_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable
    (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.CallingShellApp_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503)
    . (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.CapturePicker_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503).
    (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.NarratorQuickStart_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (5
    03). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.ParentalControls_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503
    ). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.PeopleExperienceHost_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable
    (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.PinningConfirmationDialog_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavail
    able (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.SecHealthUI_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (E
    xception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.SecureAssessmentBrowser_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailab
    le (503). (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Windows.XGpuEjectDialog_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503)
    . (Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.XboxGameCallableUI_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Ex
    ception from HRESULT: 0x801901F7)
    WARNING: Error updating app NcsiUwpApp_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception from HRESU
    LT: 0x801901F7)
    WARNING: Error updating app Windows.CBSPreview_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception fr
    om HRESULT: 0x801901F7)
    WARNING: Error updating app Windows.PrintDialog_cw5n1h2txyewy (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception f
    rom HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.BingWeather_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception
    from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.GetHelp_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception fro
    m HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Getstarted_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception
    from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.HEIFImageExtension_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Ex
    ception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Microsoft3DViewer_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exc
    eption from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MicrosoftOfficeHub_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Ex
    ception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MicrosoftStickyNotes_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (
    Exception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MixedReality.Portal_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (E
    xception from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.MSPaint_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception fro
    m HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.Office.OneNote_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Except
    ion from HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.People_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Service unavailable (503). (Exception from
    HRESULT: 0x801901F7)
    WARNING: Error updating app Microsoft.ScreenSketch_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.SkypeApp_kzf8qxf38zg5c (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.StorePurchaseApp_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x802480
    14
    WARNING: Error updating app Microsoft.VP9VideoExtensions_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x8024
    8014
    WARNING: Error updating app Microsoft.Wallet_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.WebMediaExtensions_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x8024
    8014
    WARNING: Error updating app Microsoft.WebpImageExtension_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x8024
    8014
    WARNING: App is not available on the Microsoft Store: Microsoft.Windows.Ai.Copilot.Provider_8wekyb3d8bbwe
    WARNING: Error updating app Microsoft.WindowsAlarms_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.WindowsCalculator_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248
    014
    WARNING: Error updating app Microsoft.WindowsFeedbackHub_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x8024
    8014
    WARNING: Error updating app Microsoft.WindowsMaps_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.WindowsSoundRecorder_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80
    248014
    WARNING: Error updating app Microsoft.Xbox.TCUI_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.XboxApp_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.XboxGameOverlay_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x8024801
    4
    WARNING: Error updating app Microsoft.XboxGamingOverlay_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248
    014
    WARNING: Error updating app Microsoft.XboxSpeechToTextOverlay_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0
    x80248014
    WARNING: Error updating app Microsoft.YourPhone_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.ZuneMusic_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.ZuneVideo_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.UI.Xaml.2.0_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.DesktopAppInstaller_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x802
    48014
    WARNING: Error updating app Microsoft.Windows.Photos_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.NET.Native.Framework.1.7_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT:
    0x80248014
    WARNING: Error updating app Microsoft.NET.Native.Runtime.1.7_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x
    80248014
    WARNING: Error updating app Microsoft.WindowsCamera_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app Microsoft.Advertising.Xaml_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x802480
    14
    WARNING: Error updating app Microsoft.WindowsStore_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80248014
    WARNING: Error updating app microsoft.windowscommunicationsapps_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT:
    0x80248014
    WARNING: Error updating app Microsoft.XboxIdentityProvider_8wekyb3d8bbwe (perhaps it is not installed): System.Exception: Exception from HRESULT: 0x80
    248014

    PS C:WINDOWSsystem32>

    Like

  5. This looks way easier than the solution I came up with. I was scraping URLs from Windows Store using Fiddler, downloading the relevant packages to a repository in the domain, then updating with a startup script.

    Like

Trending