Add-AppPackage does not work on powershell 7 and gives the error: Operation is not supported on this platform. (0x80131539)

See original GitHub issue

Prerequisites

Steps to reproduce

Add-AppPackage is not working on powershell 7 and gives the error: “Operation is not supported on this platform. (0x80131539)”. The same command works on windows powershell.

Expected behavior

The Add-AppPackage to work

Actual behavior

Add-AppPackage does not work on powershell 7 and gives the error: Operation is not supported on this platform. (0x80131539)

Error details

Exception             :
    Type       : System.PlatformNotSupportedException
    TargetSite :
        Name          : GetExportedTypes
        DeclaringType : System.Reflection.RuntimeAssembly, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral,
PublicKeyToken=7cec85d7bea7798e
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    Message    : Operation is not supported on this platform. (0x80131539)
    Source     : System.Private.CoreLib
    HResult    : -2146233031
    StackTrace :
   at System.Reflection.RuntimeAssembly.GetExportedTypes()
   at System.Management.Automation.Runspaces.PSSnapInHelpers.GetAssemblyTypes(Assembly assembly, String name)
   at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzeModuleAssemblyWithReflection(Assembly assembly,
String name, PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, String helpFile, Dictionary`2& cmdlets, Dictionary`2&
aliases, Dictionary`2& providers)
   at System.Management.Automation.Runspaces.PSSnapInHelpers.AnalyzePSSnapInAssembly(Assembly assembly, String name,
PSSnapInInfo psSnapInInfo, PSModuleInfo moduleInfo, Dictionary`2& cmdlets, Dictionary`2& aliases, Dictionary`2&
providers, String& helpFile)
   at System.Management.Automation.Runspaces.InitialSessionState.ImportCmdletsFromAssembly(Assembly assembly,
PSModuleInfo module)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadBinaryModule(PSModuleInfo parentModule, String moduleName,
String fileName, Assembly assemblyToLoad, String moduleBase, SessionState ss, ImportModuleOptions options,
ManifestProcessingFlags manifestProcessingFlags, String prefix, Boolean& found, String shortModuleName, Boolean
disableFormatUpdates)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleNamedInManifest(PSModuleInfo parentModule,
ModuleSpecification moduleSpecification, String moduleBase, Boolean searchModulePath, String prefix, SessionState ss,
ImportModuleOptions options, ManifestProcessingFlags manifestProcessingFlags, Object privateData, Boolean& found,
String shortModuleName, Nullable`1 manifestLanguageMode)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModuleManifest(String moduleManifestPath, ExternalScriptInfo
manifestScriptInfo, Hashtable data, Hashtable localizedData, ManifestProcessingFlags manifestProcessingFlags, Version
minimumVersion, Version maximumVersion, Version requiredVersion, Nullable`1 requiredModuleGuid, ImportModuleOptions&
options, Boolean& containedErrors)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadModule(PSModuleInfo parentModule, String fileName, String
moduleBase, String prefix, SessionState ss, Object privateData, ImportModuleOptions& options, ManifestProcessingFlags
manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingExtensions(PSModuleInfo parentModule, String moduleName,
String fileBaseName, String extension, String moduleBase, String prefix, SessionState ss, ImportModuleOptions options,
ManifestProcessingFlags manifestProcessingFlags, Boolean& found, Boolean& moduleFileFound)
   at Microsoft.PowerShell.Commands.ModuleCmdletBase.LoadUsingModulePath(PSModuleInfo parentModule, IEnumerable`1
modulePath, String name, SessionState ss, ImportModuleOptions options, ManifestProcessingFlags
manifestProcessingFlags, PSModuleInfo& module)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName(ImportModuleOptions
importModuleOptions, String name)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ImportModule_LocallyViaName_WithTelemetry(ImportModuleOptions
importModuleOptions, String name)
   at Microsoft.PowerShell.Commands.ImportModuleCommand.ProcessRecord()
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Import-Module], PlatformNotSupportedException
FullyQualifiedErrorId : System.PlatformNotSupportedException,Microsoft.PowerShell.Commands.ImportModuleCommand
InvocationInfo        :
    MyCommand        : Import-Module
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 1
    Line             : Import-Module Appx
    PositionMessage  : At line:1 char:1
                       + Import-Module Appx
                       + ~~~~~~~~~~~~~~~~~~
    InvocationName   : Import-Module
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

Name                           Value
----                           -----
PSVersion                      7.3.2
PSEdition                      Core
GitCommitId                    7.3.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

image

Issue Analytics

  • State:closed
  • Created 8 months ago
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
SeeminglySciencecommented, Jan 27, 2023

It would be nice if Powershell 7 could add support for WinRT, but I suppose that is more of a low-priority feature request.

Unfortunately nothing we do would help with the AppX module specifically. The .NET runtime throws as soon as it reads the assembly reference to WinRT. There are some ways that WinRT could be supported, but that module would still need to be updated.

1reaction
Xehlwancommented, Jan 27, 2023

Unfortunately for anyone who can’t upgrade to Win11, latest Win10, as of today, only has Windows Powershell v5.1.19041.2364. At least we found that there are workarounds. Hope that helps anyone else who runs into this issue.

It would be nice if Powershell 7 could add support for WinRT, but I suppose that is more of a low-priority feature request.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Powershell Get-AppxPackage not working
For more information, run 'Import-Module Appx'. # Import-Module Appx Import-Module: Operation is not supported on this platform.
Read more >
Windows Store and Xbox app no longer working
Get-AppXPackage: The 'Get-AppXPackage' command was found in the module 'Appx', but the module could not be loaded. For more information, run ' ...
Read more >
Issue with Windows Defender on Windows 11 - Page 9
Import-Module: Operation is not supported on this platform. (0x80131539). Instead, I had to do the following steps: Start PowerShell and ...
Read more >
Fix Powershell Get-AppxPackage not working - YouTube
This Tutorial Helps to Fix Powershell Get-AppxPackage not working # PowerShell ... Fix get-appxpackage error in Powershell.
Read more >
Powershell Get-AppxPackage not working in Windows 11/10
After rebooting your computer, try to use the 'Get-AppXPackage' command in the shell terminal again. This should solve the problem. Fix 2 – ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found