Get-AppxPackage: The database disk image is malformed

You may be unable to install or update Store apps. Also, when you run the Get-AppxPackage command, the following error may appear:

Get-AppxPackage : The database disk image is malformed
The database disk image is malformed
At line:1 char:1
+ Get-AppxPackage
+ ~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-AppxPackage], Exception
+ FullyQualifiedErrorId : System.Exception,Microsoft.Windows.Appx.PackageManager.Commands.GetAppxPackageCommand

Cause

The “The database disk image is malformed” occurs if the State Repository database is corrupt. This database stores information about every Store app installed on the computer. The database file names are below:

  • StateRepository-Deployment.srd
  • StateRepository-Deployment.srd-shm
  • StateRepository-Deployment.srd-wal
  • StateRepository-Machine.srd
  • StateRepository-Machine.srd-shm
  • StateRepository-Machine.srd-wal

Unfortunately, a repair installation using an in-place upgrade using the ISO may not resolve the issue.

However, resetting the StateRepository databases manually should fix the issue.

Resolution

To fix the error “The database disk image is malformed”, rebuild the State Repository database.



Important: Following the procedure below, you will lose all your installed Store apps, but you can reinstall them again.

Rebuilding the State Repository database

  1. Download AdvancedRun from Nirsoft.net.
  2. Using AdvancedRun, open a TrustedInstaller Command Prompt. See the screenshot below.
    advancedrun - trustedinstaller

  3. After the Command Prompt window opens, close the AdvancedRun utility.
  4. In the TrustedInstaller Command Prompt, run the following commands:
    cd /d C:\ProgramData\Microsoft\Windows\AppRepository
    
    net stop StateRepository
    
    md C:\SRBackup
    
    move StateRepository-*   C:\SRBackup

    rebuild the state repository database

The above procedure moves the existing State Repository database files to a folder for backup purposes.

Restart Windows. Or, click the Start button or an item in your notification area. This starts the State Repository service automatically and rebuilds the databases. A fresh set of StateRespository-* databases will be created. The newly built database will not contain information about your previously installed Store apps.

This resolves the error “The database disk image is malformed” when running Get-AppxPackage and allows you to install the Store apps.


One small request: If you liked this post, please share this?

One "tiny" share from you would seriously help a lot with the growth of this blog. Some great suggestions:
  • Pin it!
  • Share it to your favorite blog + Facebook, Reddit
  • Tweet it!
So thank you so much for your support. It won't take more than 10 seconds of your time. The share buttons are right below. :)

Ramesh Srinivasan is passionate about Microsoft technologies and he has been a consecutive ten-time recipient of the Microsoft Most Valuable Professional award in the Windows Shell/Desktop Experience category, from 2003 to 2012. He loves to troubleshoot and write about Windows. Ramesh founded Winhelponline.com in 2005.

Leave a Comment