Get-AppxPackage Not responding

Can anyone advise me why I don’t seem to be able to run the Get-AppxPackage command?

PS C:\WINDOWS\system32> get-appxpackage -AllUsers
get-appxpackage : The service did not respond to the start or control request in a timely fashion.
The service did not respond to the start or control request in a timely fashion.
At line:1 char:1
+ get-appxpackage -AllUsers
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AppxPackage], Exception
    + FullyQualifiedErrorId : System.Exception,Microsoft.Windows.Appx.PackageManager.Commands.GetAppxPackageCommand

PS C:\WINDOWS\system32>

Other Appx commands work fine e.g. Get-AppxVolume, Get-AppxLog

Not sure if this is connected but I also get the following error when using the Get-AppxProvisionedPackage command

PS C:\WINDOWS\system32> Get-AppxProvisionedPackage -Path "C:\Program Files\WindowsApps"
Get-AppxProvisionedPackage : An error occurred. No operation was performed.
Verify that DISM is installed properly in the image, and then try the operation again.
At line:1 char:1
+ Get-AppxProvisionedPackage -Path "C:\Program Files\WindowsApps"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-AppxProvisionedPackage], COMException
    + FullyQualifiedErrorId : Microsoft.Dism.Commands.GetAppxProvisionedPackageCommand

How many entries are at this registry key? I’ve seen it go over 250,000. It grows without bounds with the number of profiles created. Deleting profiles does nothing to clean it. It can cause the start menu and search to stop working, and pretty much break the whole app system. This is only one example.

(get-item HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\RestrictedServices\Appiso\FirewallRules).valuecount

For the example you gave I got a count of 923 - Is that excessive? What is the recommended method for cleaning up the registry key(s)? Grateful for any further help you can provide.

PS C:\WINDOWS\system32> (get-item HKLM:\SYSTEM\CurrentControlSet\Services\SharedAccess\Parameters\FirewallPolicy\Restric
PS C:\WINDOWS\system32>

It’s not that bad. There are no recommendations. Have you tried a new profile?

I tried creating a new Admin profile and had exactly the symptoms you described - No start menu or search capability.

Most of the threads I have looked at for this problem point to a PS cmdlet that uses Get-AppxPackage - hence my original question because I need to get Get-AppxPackage working to try that solution.