Skip to content

DISM Commands Enable-windowsOptionalFeature and Add-WindowsPackage fail when PowerShell is installed by MSIX #27358

Description

@paul-da

Prerequisites

Steps to reproduce

These errors occur whether installing PowerShell 7 from the Microsoft Store or the latest MSIX files available on the GitHub download page.

Using Windows PowerShell / 5.1 or using the MSI installer of 7.6.1 the commands work as expected.

Possibly related to: #13866

Expected behavior

Enable-windowsOptionalFeature -FeatureName netfx3 -LimitAccess -Source d:\sources\sxs\ -Path C:\Mount\

Path          : C:\Mount\
Online        : False
RestartNeeded : False

Add-WindowsPackage -PackagePath .\Downloads\Patch_Testing\MSU\DOTNET.windows11.0-kb5082417-x64-ndp481.msu -Path C:\Mount\

Path          : C:\Mount\
Online        : False
RestartNeeded : Fals

Actual behavior

Mount-WindowsImage -ImagePath .\Downloads\install.wim -Index 6 -Path C:\Mount\

Enable-windowsOptionalFeature -FeatureName netfx3 -LimitAccess -Source d:\sources\sxs\ -Path C:\Mount\
Enable-WindowsOptionalFeature: Class not registered

Add-WindowsPackage -PackagePath .\Downloads\Patch_Testing\MSU\DOTNET.windows11.0-kb5082417-x64-ndp481.msu -Path C:\Mount
Add-WindowsPackage: Class not registered

Error details

get-Error

Exception             :
    Type       : System.Runtime.InteropServices.COMException
    ErrorCode  : -2147221164
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : [System.Management.Automation.MshCommandRuntime]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Class not registered

    Source     : System.Management.Automation
    HResult    : -2147221164
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
CategoryInfo          : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException
FullyQualifiedErrorId : Microsoft.Dism.Commands.EnableWindowsOptionalFeatureCommand
InvocationInfo        :
    MyCommand        : Enable-WindowsOptionalFeature
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 7
    Line             : enable-windowsOptionalFeature -FeatureName netfx3 -LimitAccess -Source d:\sources\sxs\ -Path
C:\Mount\
    Statement        : enable-windowsOptionalFeature -FeatureName netfx3 -LimitAccess -Source d:\sources\sxs\ -Path
C:\Mount\
    PositionMessage  : At line:1 char:1
                       + enable-windowsOptionalFeature -FeatureName netfx3 -LimitAccess -Sourc …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : enable-windowsOptionalFeature
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1






Get-Error

Exception             :
    Type       : System.Runtime.InteropServices.COMException
    ErrorCode  : -2147221164
    TargetSite :
        Name          : ThrowTerminatingError
        DeclaringType : [System.Management.Automation.MshCommandRuntime]
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message    : Class not registered

    Source     : System.Management.Automation
    HResult    : -2147221164
    StackTrace :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
CategoryInfo          : NotSpecified: (:) [Add-WindowsPackage], COMException
FullyQualifiedErrorId : Microsoft.Dism.Commands.AddWindowsPackageCommand
InvocationInfo        :
    MyCommand        : Add-WindowsPackage
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 5
    Line             : add-WindowsPackage -PackagePath
.\Downloads\Patch_Testing\MSU\DOTNET.windows11.0-kb5082417-x64-ndp481.msu -Path C:\Mount\
    Statement        : add-WindowsPackage -PackagePath
.\Downloads\Patch_Testing\MSU\DOTNET.windows11.0-kb5082417-x64-ndp481.msu -Path C:\Mount\
    PositionMessage  : At line:1 char:1
                       + add-WindowsPackage -PackagePath .\Downloads\Patch_Testing\MSU\DOTNET. …
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : add-WindowsPackage
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

$PSVersionTable

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

Visuals

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions