Skip to content

902848b76bcdcf55438ba99e584d852f48c03859/diagnostics/collect-wsl-logs.ps1 fails with "Class not registered". #13224

Closed

Description

Windows Version

10.0.26120

WSL Version

2.6.0.0

Are you using WSL 1 or WSL 2?

  1. WSL 2

  2. WSL 1

Kernel Version

6.6.87.2-1

Distro Version

The .MSIXBundle from WhitewaterFoundry/Fedora-Remix-for-WSL/releases/tag/42.0.5

Other Software

Get-AppxPackage Microsoft.PowerShellPreview | Format-List returns:

Publisher         : CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US
ResourceId        :
InstallLocation   : C:\Program Files\WindowsApps\Microsoft.PowerShellPreview_7.6.4.0_x64__8wekyb3d8bbwe
IsFramework       : False
IsResourcePackage : False
IsBundle          : False
IsDevelopmentMode : False
NonRemovable      : False
IsPartiallyStaged : False
SignatureKind     : Store
Status            : Ok

Repro Steps

#!/usr/bin/env pwsh
#Requires -PSEdition Core
#Requires -Version 7.6.0

If ($IsWindows) {
	$OutFile = "$Home" + [IO.Path]::DirectorySeparatorChar + 'collect-wsl-logs.ps1'
	Invoke-WebRequest `
		-URI 'https://github.com/microsoft/WSL/raw/902848b76bcdcf55438ba99e584d852f48c03859/diagnostics/collect-wsl-logs.ps1' `
		-OutFile "$OutFile"
	& $('./' + [IO.Path]::DirectorySeparatorChar + "$OutFile")
}

Expected Behavior

It should operate.

Actual Behavior

As I've explained at #13169 (comment), 902848b76bcdcf55438ba99e584d852f48c03859/diagnostics/collect-wsl-logs.ps1, it fails:

Image

Details

Evidential Logs

PS C:\Users\rokej> Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
PS C:\Users\rokej> Set-ExecutionPolicy Bypass -Scope Process -Force
PS C:\Users\rokej> .\collect-wsl-logs.ps1
Get-WindowsOptionalFeature: C:\Users\rokej\collect-wsl-logs.ps1:57
Line |
  57 |  Get-WindowsOptionalFeature -Online > $folder/optional-components.txt
     |  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Class not registered
100%  [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]e press any key to save the logs.

...as the subsequent section confirms.

Diagnostic Logs

See #13166 (comment):

If the CLIXML proves it, Get-Error | Export-CLIXML "$Filename" returns:

<Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
  <Obj RefId="0">
    <TN RefId="0">
      <T>System.Management.Automation.ErrorRecord#PSExtendedError</T>
      <T>System.Object</T>
    </TN>
    <ToString>Class not registered_x000D__x000A_</ToString>
    <MS>
      <Obj N="Exception" RefId="1">
        <TN RefId="1">
          <T>System.Runtime.InteropServices.COMException</T>
          <T>System.Runtime.InteropServices.ExternalException</T>
          <T>System.SystemException</T>
          <T>System.Exception</T>
          <T>System.Object</T>
        </TN>
        <ToString>System.Runtime.InteropServices.COMException (0x80040154): Class not registered_x000D__x000A__x000D__x000A_   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)</ToString>
        <Props>
          <I32 N="ErrorCode">-2147221164</I32>
          <S N="TargetSite">Void ThrowTerminatingError(System.Management.Automation.ErrorRecord)</S>
          <S N="Message">Class not registered_x000D__x000A_</S>
          <Obj N="Data" RefId="2">
            <TN RefId="2">
              <T>System.Collections.ListDictionaryInternal</T>
              <T>System.Object</T>
            </TN>
            <DCT />
          </Obj>
          <Nil N="InnerException" />
          <Nil N="HelpLink" />
          <S N="Source">System.Management.Automation</S>
          <I32 N="HResult">-2147221164</I32>
          <S N="StackTrace">   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)</S>
        </Props>
      </Obj>
      <Nil N="TargetObject" />
      <S N="FullyQualifiedErrorId">Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand</S>
      <Obj N="InvocationInfo" RefId="3">
        <TN RefId="3">
          <T>System.Management.Automation.InvocationInfo</T>
          <T>System.Object</T>
        </TN>
        <ToString>System.Management.Automation.InvocationInfo</ToString>
        <Props>
          <Obj N="MyCommand" RefId="4">
            <TN RefId="4">
              <T>System.Management.Automation.CmdletInfo</T>
              <T>System.Management.Automation.CommandInfo</T>
              <T>System.Object</T>
            </TN>
            <ToString>Get-WindowsOptionalFeature</ToString>
            <Props>
              <S N="Verb">Get</S>
              <S N="Noun">WindowsOptionalFeature</S>
              <S N="HelpFile">Microsoft.Dism.PowerShell.dll-Help.xml</S>
              <Nil N="PSSnapIn" />
              <Version N="Version">3.0</Version>
              <S N="ImplementingType">Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand</S>
              <S N="Definition">_x000D__x000A_Get-WindowsOptionalFeature -Path &lt;string&gt; [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]_x000D__x000A__x000D__x000A_Get-WindowsOptionalFeature -Online [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]_x000D__x000A_</S>
              <Nil N="DefaultParameterSet" />
              <Obj N="OutputType" RefId="5">
                <TN RefId="5">
                  <T>System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTypeName, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                  <T>System.Object</T>
                </TN>
                <LST>
                  <S>System.Collections.Generic.List`1[[Microsoft.Dism.Commands.BasicFeatureObject, Microsoft.Dism.PowerShell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null]]</S>
                  <S>Microsoft.Dism.Commands.AdvancedFeatureObject</S>
                </LST>
              </Obj>
              <S N="Options">ReadOnly</S>
              <S N="Name">Get-WindowsOptionalFeature</S>
              <S N="CommandType">Cmdlet</S>
              <S N="Source">Dism</S>
              <S N="Visibility">Public</S>
              <S N="ModuleName">Dism</S>
              <S N="Module">Dism</S>
              <S N="RemotingCapability">PowerShell</S>
              <Obj N="Parameters" RefId="6">
                <TN RefId="6">
                  <T>System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.ParameterMetadata, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                  <T>System.Object</T>
                </TN>
                <DCT>
                  <En>
                    <S N="Key">FeatureName</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">PackageName</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">PackagePath</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">Path</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">Online</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">WindowsDirectory</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">SystemDrive</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">LogPath</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">ScratchDirectory</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">LogLevel</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">Verbose</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">Debug</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">ErrorAction</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">WarningAction</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">InformationAction</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">ProgressAction</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">ErrorVariable</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">WarningVariable</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">InformationVariable</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">OutVariable</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">OutBuffer</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                  <En>
                    <S N="Key">PipelineVariable</S>
                    <S N="Value">System.Management.Automation.ParameterMetadata</S>
                  </En>
                </DCT>
              </Obj>
              <Obj N="ParameterSets" RefId="7">
                <TN RefId="7">
                  <T>System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.CommandParameterSetInfo, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                  <T>System.Object</T>
                </TN>
                <LST>
                  <S>-Path &lt;string&gt; [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]</S>
                  <S>-Online [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]</S>
                </LST>
              </Obj>
            </Props>
            <MS>
              <S N="Namespace">Dism</S>
              <S N="HelpUri">https://go.microsoft.com/fwlink/?LinkId=289358</S>
              <S N="DLL">C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Dism\Microsoft.Dism.PowerShell.dll</S>
            </MS>
          </Obj>
          <Obj N="BoundParameters" RefId="8">
            <TN RefId="8">
              <T>System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
              <T>System.Object</T>
            </TN>
            <DCT />
          </Obj>
          <Obj N="UnboundArguments" RefId="9">
            <TN RefId="9">
              <T>System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
              <T>System.Object</T>
            </TN>
            <LST />
          </Obj>
          <I32 N="ScriptLineNumber">57</I32>
          <I32 N="OffsetInLine">1</I32>
          <I64 N="HistoryId">3</I64>
          <S N="ScriptName">C:\Users\rokej\collect-wsl-logs.ps1</S>
          <S N="Line">Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt_x000A_</S>
          <S N="Statement">Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt</S>
          <S N="PositionMessage">At C:\Users\rokej\collect-wsl-logs.ps1:57 char:1_x000D__x000A_+ Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt_x000D__x000A_+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</S>
          <S N="PSScriptRoot">C:\Users\rokej</S>
          <S N="PSCommandPath">C:\Users\rokej\collect-wsl-logs.ps1</S>
          <S N="InvocationName">Get-WindowsOptionalFeature</S>
          <I32 N="PipelineLength">0</I32>
          <I32 N="PipelinePosition">0</I32>
          <B N="ExpectingInput">false</B>
          <Obj N="CommandOrigin" RefId="10">
            <TN RefId="10">
              <T>System.Management.Automation.CommandOrigin</T>
              <T>System.Enum</T>
              <T>System.ValueType</T>
              <T>System.Object</T>
            </TN>
            <ToString>Internal</ToString>
            <I32>1</I32>
          </Obj>
          <Nil N="DisplayScriptPosition" />
        </Props>
      </Obj>
      <I32 N="ErrorCategory_Category">0</I32>
      <S N="ErrorCategory_Activity">Get-WindowsOptionalFeature</S>
      <S N="ErrorCategory_Reason">COMException</S>
      <S N="ErrorCategory_TargetName"></S>
      <S N="ErrorCategory_TargetType"></S>
      <S N="ErrorCategory_Message">NotSpecified: (:) [Get-WindowsOptionalFeature], COMException</S>
      <B N="SerializeExtendedInfo">false</B>
      <S N="ErrorDetails_ScriptStackTrace">at &lt;ScriptBlock&gt;, C:\Users\rokej\collect-wsl-logs.ps1: line 57_x000D__x000A_at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 1</S>
    </MS>
  </Obj>
</Objs>

Activity

  1. github-actions commented on Jul 4, 2025

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use collect-networking-logs.ps1, following the instructions here

    Once completed please upload the output files to this Github issue.

    Click here for more info on logging
    If you choose to email these logs instead of attaching to the bug, please send them to [email protected] with the number of the github issue in the subject, and in the message a link to your comment in the github issue and reply with '/emailed-logs'.

  2. beedell-roke commented on Jul 4, 2025

    @beedell-roke
    Author

    #13224 (comment)

    Triage assignee, please prevent this bot activating on this report.

  3. zcobol commented on Jul 5, 2025

    @zcobol

    @RokeJulianLockhart are you trying to run the scrip from within WSL? If you run it as Administrator on Windows side there are no issues:

    PS C:\Users\zcobo> .\collect-wsl-logs.ps1
    Log collection is running. Please reproduce the problem and once done press any key to save the logs.
    Saving logs...
    100%  [>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>]
    Logs saved in: C:\Users\zcobo\WslLogs-2025-07-05_13-20-41.zip. Please attach that file to the GitHub issue.
    
  4. beedell-roke commented on Jul 5, 2025

    @beedell-roke
    Author

    Are you trying to run the script from within WSL?

    Toto (@zcobol), no. I realise that PowerShell Core supports Linux, but I was under the impression that this script is designed to be invoked on the host Windows installation. Should it be?

    If you run it as Administrator, on the Windows, side there are no issues:

    Considering you've a preprocessor statement at L1, I can't imagine that it's possible to invoke otherwise. It certainly doesn't appear to be possible, when I attempt to invoke it outside of Administrator mode:

    Details
    <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
      <Obj RefId="0">
        <TN RefId="0">
          <T>System.Management.Automation.ErrorRecord#PSExtendedError</T>
          <T>System.Object</T>
        </TN>
        <ToString>The script 'collect-wsl-logs.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current PowerShell session is not running as Administrator. Start PowerShell by using the Run as Administrator option, and then try running the script again.</ToString>
        <MS>
          <Obj N="Exception" RefId="1">
            <TN RefId="1">
              <T>System.Management.Automation.ScriptRequiresException</T>
              <T>System.Management.Automation.RuntimeException</T>
              <T>System.SystemException</T>
              <T>System.Exception</T>
              <T>System.Object</T>
            </TN>
            <ToString>System.Management.Automation.ScriptRequiresException: The script 'collect-wsl-logs.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current PowerShell session is not running as Administrator. Start PowerShell by using the Run as Administrator option, and then try running the script again._x000D__x000A_   at System.Management.Automation.CommandDiscovery.VerifyElevatedPrivileges(ExternalScriptInfo scriptInfo)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.VerifyScriptRequirements(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.CreateScriptProcessorForSingleShell(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useLocalScope, SessionStateInternal sessionState, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)_x000D__x000A_   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)_x000D__x000A_   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)_x000D__x000A_   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)</ToString>
            <Props>
              <S N="CommandName">collect-wsl-logs.ps1</S>
              <Nil N="RequiresPSVersion" />
              <Obj N="MissingPSSnapIns" RefId="2">
                <TN RefId="2">
                  <T>System.Collections.ObjectModel.ReadOnlyCollection`1[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
                  <T>System.Object</T>
                </TN>
                <LST />
              </Obj>
              <Nil N="RequiresShellId" />
              <Nil N="RequiresShellPath" />
              <S N="ErrorRecord">The script 'collect-wsl-logs.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current PowerShell session is not running as Administrator. Start PowerShell by using the Run as Administrator option, and then try running the script again.</S>
              <B N="WasThrownFromThrowStatement">false</B>
              <S N="TargetSite">Void VerifyElevatedPrivileges(System.Management.Automation.ExternalScriptInfo)</S>
              <S N="Message">The script 'collect-wsl-logs.ps1' cannot be run because it contains a "#requires" statement for running as Administrator. The current PowerShell session is not running as Administrator. Start PowerShell by using the Run as Administrator option, and then try running the script again.</S>
              <Obj N="Data" RefId="3">
                <TN RefId="3">
                  <T>System.Collections.ListDictionaryInternal</T>
                  <T>System.Object</T>
                </TN>
                <DCT>
                  <En>
                    <S N="Key">System.Management.Automation.Interpreter.InterpretedFrameInfo</S>
                    <Obj N="Value" RefId="4">
                      <TN RefId="4">
                        <T>System.Management.Automation.Interpreter.InterpretedFrameInfo[]</T>
                        <T>System.Array</T>
                        <T>System.Object</T>
                      </TN>
                      <LST>
                        <S>&lt;ScriptBlock&gt;</S>
                      </LST>
                    </Obj>
                  </En>
                </DCT>
              </Obj>
              <Nil N="InnerException" />
              <Nil N="HelpLink" />
              <S N="Source">System.Management.Automation</S>
              <I32 N="HResult">-2146233087</I32>
              <S N="StackTrace">   at System.Management.Automation.CommandDiscovery.VerifyElevatedPrivileges(ExternalScriptInfo scriptInfo)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.VerifyScriptRequirements(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.CreateScriptProcessorForSingleShell(ExternalScriptInfo scriptInfo, ExecutionContext context, Boolean useLocalScope, SessionStateInternal sessionState, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(CommandInfo commandInfo, CommandOrigin commandOrigin, Nullable`1 useLocalScope, SessionStateInternal sessionState, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource, Boolean forCompletion)_x000D__x000A_   at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst, CommandRedirection[] redirections, ExecutionContext context)_x000D__x000A_   at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[] pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)_x000D__x000A_   at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)_x000D__x000A_   at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)</S>
            </Props>
          </Obj>
          <S N="TargetObject">collect-wsl-logs.ps1</S>
          <S N="FullyQualifiedErrorId">ScriptRequiresElevation</S>
          <Obj N="InvocationInfo" RefId="5">
            <TN RefId="5">
              <T>System.Management.Automation.InvocationInfo</T>
              <T>System.Object</T>
            </TN>
            <ToString>System.Management.Automation.InvocationInfo</ToString>
            <Props>
              <Nil N="MyCommand" />
              <Obj N="BoundParameters" RefId="6">
                <TN RefId="6">
                  <T>System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
                  <T>System.Object</T>
                </TN>
                <DCT />
              </Obj>
              <Obj N="UnboundArguments" RefId="7">
                <TN RefId="7">
                  <T>System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
                  <T>System.Object</T>
                </TN>
                <LST />
              </Obj>
              <I32 N="ScriptLineNumber">1</I32>
              <I32 N="OffsetInLine">3</I32>
              <I64 N="HistoryId">1</I64>
              <S N="ScriptName"></S>
              <S N="Line">&amp; "$Env:UserProfile\Downloads\collect-wsl-logs.ps1"</S>
              <S N="Statement">"$Env:UserProfile\Downloads\collect-wsl-logs.ps1"</S>
              <S N="PositionMessage">At line:1 char:3_x000D__x000A_+ &amp; "$Env:UserProfile\Downloads\collect-wsl-logs.ps1"_x000D__x000A_+   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</S>
              <S N="PSScriptRoot"></S>
              <Nil N="PSCommandPath" />
              <S N="InvocationName">&amp;</S>
              <I32 N="PipelineLength">0</I32>
              <I32 N="PipelinePosition">0</I32>
              <B N="ExpectingInput">false</B>
              <Obj N="CommandOrigin" RefId="8">
                <TN RefId="8">
                  <T>System.Management.Automation.CommandOrigin</T>
                  <T>System.Enum</T>
                  <T>System.ValueType</T>
                  <T>System.Object</T>
                </TN>
                <ToString>Internal</ToString>
                <I32>1</I32>
              </Obj>
              <Nil N="DisplayScriptPosition" />
            </Props>
          </Obj>
          <I32 N="ErrorCategory_Category">18</I32>
          <S N="ErrorCategory_Activity"></S>
          <S N="ErrorCategory_Reason">ScriptRequiresException</S>
          <S N="ErrorCategory_TargetName">collect-wsl-logs.ps1</S>
          <S N="ErrorCategory_TargetType">String</S>
          <S N="ErrorCategory_Message">PermissionDenied: (collect-wsl-logs.ps1:String) [], ScriptRequiresException</S>
          <B N="SerializeExtendedInfo">false</B>
          <S N="ErrorDetails_ScriptStackTrace">at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 1</S>
        </MS>
      </Obj>
    </Objs>

    Irrespective, when I invoke it in a shell spawned from an administrative instance of wt, 1 the same error occurs:

    1. #!/usr/bin/env pwsh
      #Requires -PSEdition Core
      #Requires -Version 7.6.0
      #Requires -RunAsAdministrator
      If ($IsWindows) {
      	& "$Env:UserProfile\Downloads\collect-wsl-logs.ps1"
      	If ($? -Eq $True) { Get-Error -Newest 1 | Export-CLIXML -LiteralPath "$Home/CLIXML4.XML" }
      }
    2. <Objs Version="1.1.0.1" xmlns="http://schemas.microsoft.com/powershell/2004/04">
        <Obj RefId="0">
          <TN RefId="0">
            <T>System.Management.Automation.ErrorRecord#PSExtendedError</T>
            <T>System.Object</T>
          </TN>
          <ToString>Class not registered_x000D__x000A_</ToString>
          <MS>
            <Obj N="Exception" RefId="1">
              <TN RefId="1">
                <T>System.Runtime.InteropServices.COMException</T>
                <T>System.Runtime.InteropServices.ExternalException</T>
                <T>System.SystemException</T>
                <T>System.Exception</T>
                <T>System.Object</T>
              </TN>
              <ToString>System.Runtime.InteropServices.COMException (0x80040154): Class not registered_x000D__x000A__x000D__x000A_   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)</ToString>
              <Props>
                <I32 N="ErrorCode">-2147221164</I32>
                <S N="TargetSite">Void ThrowTerminatingError(System.Management.Automation.ErrorRecord)</S>
                <S N="Message">Class not registered_x000D__x000A_</S>
                <Obj N="Data" RefId="2">
                  <TN RefId="2">
                    <T>System.Collections.ListDictionaryInternal</T>
                    <T>System.Object</T>
                  </TN>
                  <DCT />
                </Obj>
                <Nil N="InnerException" />
                <Nil N="HelpLink" />
                <S N="Source">System.Management.Automation</S>
                <I32 N="HResult">-2147221164</I32>
                <S N="StackTrace">   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)</S>
              </Props>
            </Obj>
            <Nil N="TargetObject" />
            <S N="FullyQualifiedErrorId">Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand</S>
            <Obj N="InvocationInfo" RefId="3">
              <TN RefId="3">
                <T>System.Management.Automation.InvocationInfo</T>
                <T>System.Object</T>
              </TN>
              <ToString>System.Management.Automation.InvocationInfo</ToString>
              <Props>
                <Obj N="MyCommand" RefId="4">
                  <TN RefId="4">
                    <T>System.Management.Automation.CmdletInfo</T>
                    <T>System.Management.Automation.CommandInfo</T>
                    <T>System.Object</T>
                  </TN>
                  <ToString>Get-WindowsOptionalFeature</ToString>
                  <Props>
                    <S N="Verb">Get</S>
                    <S N="Noun">WindowsOptionalFeature</S>
                    <S N="HelpFile">Microsoft.Dism.PowerShell.dll-Help.xml</S>
                    <Nil N="PSSnapIn" />
                    <Version N="Version">3.0</Version>
                    <S N="ImplementingType">Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand</S>
                    <S N="Definition">_x000D__x000A_Get-WindowsOptionalFeature -Path &lt;string&gt; [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]_x000D__x000A__x000D__x000A_Get-WindowsOptionalFeature -Online [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]_x000D__x000A_</S>
                    <Nil N="DefaultParameterSet" />
                    <Obj N="OutputType" RefId="5">
                      <TN RefId="5">
                        <T>System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.PSTypeName, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                        <T>System.Object</T>
                      </TN>
                      <LST>
                        <S>System.Collections.Generic.List`1[[Microsoft.Dism.Commands.BasicFeatureObject, Microsoft.Dism.PowerShell, Version=10.0.0.0, Culture=neutral, PublicKeyToken=null]]</S>
                        <S>Microsoft.Dism.Commands.AdvancedFeatureObject</S>
                      </LST>
                    </Obj>
                    <S N="Options">ReadOnly</S>
                    <S N="Name">Get-WindowsOptionalFeature</S>
                    <S N="CommandType">Cmdlet</S>
                    <S N="Source">Dism</S>
                    <S N="Visibility">Public</S>
                    <S N="ModuleName">Dism</S>
                    <S N="Module">Dism</S>
                    <S N="RemotingCapability">PowerShell</S>
                    <Obj N="Parameters" RefId="6">
                      <TN RefId="6">
                        <T>System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Management.Automation.ParameterMetadata, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                        <T>System.Object</T>
                      </TN>
                      <DCT>
                        <En>
                          <S N="Key">FeatureName</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">PackageName</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">PackagePath</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">Path</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">Online</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">WindowsDirectory</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">SystemDrive</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">LogPath</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">ScratchDirectory</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">LogLevel</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">Verbose</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">Debug</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">ErrorAction</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">WarningAction</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">InformationAction</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">ProgressAction</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">ErrorVariable</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">WarningVariable</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">InformationVariable</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">OutVariable</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">OutBuffer</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                        <En>
                          <S N="Key">PipelineVariable</S>
                          <S N="Value">System.Management.Automation.ParameterMetadata</S>
                        </En>
                      </DCT>
                    </Obj>
                    <Obj N="ParameterSets" RefId="7">
                      <TN RefId="7">
                        <T>System.Collections.ObjectModel.ReadOnlyCollection`1[[System.Management.Automation.CommandParameterSetInfo, System.Management.Automation, Version=7.6.0.4, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]</T>
                        <T>System.Object</T>
                      </TN>
                      <LST>
                        <S>-Path &lt;string&gt; [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]</S>
                        <S>-Online [-FeatureName &lt;string&gt;] [-PackageName &lt;string&gt;] [-PackagePath &lt;string&gt;] [-WindowsDirectory &lt;string&gt;] [-SystemDrive &lt;string&gt;] [-LogPath &lt;string&gt;] [-ScratchDirectory &lt;string&gt;] [-LogLevel &lt;LogLevel&gt;] [&lt;CommonParameters&gt;]</S>
                      </LST>
                    </Obj>
                  </Props>
                  <MS>
                    <S N="Namespace">Dism</S>
                    <S N="HelpUri">https://go.microsoft.com/fwlink/?LinkId=289358</S>
                    <S N="DLL">C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Dism\Microsoft.Dism.PowerShell.dll</S>
                  </MS>
                </Obj>
                <Obj N="BoundParameters" RefId="8">
                  <TN RefId="8">
                    <T>System.Collections.Generic.Dictionary`2[[System.String, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
                    <T>System.Object</T>
                  </TN>
                  <DCT />
                </Obj>
                <Obj N="UnboundArguments" RefId="9">
                  <TN RefId="9">
                    <T>System.Collections.Generic.List`1[[System.Object, System.Private.CoreLib, Version=10.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]]</T>
                    <T>System.Object</T>
                  </TN>
                  <LST />
                </Obj>
                <I32 N="ScriptLineNumber">57</I32>
                <I32 N="OffsetInLine">1</I32>
                <I64 N="HistoryId">2</I64>
                <S N="ScriptName">C:\Users\rokej\Downloads\collect-wsl-logs.ps1</S>
                <S N="Line">Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt_x000A_</S>
                <S N="Statement">Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt</S>
                <S N="PositionMessage">At C:\Users\rokej\Downloads\collect-wsl-logs.ps1:57 char:1_x000D__x000A_+ Get-WindowsOptionalFeature -Online &gt; $folder/optional-components.txt_x000D__x000A_+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~</S>
                <S N="PSScriptRoot">C:\Users\rokej\Downloads</S>
                <S N="PSCommandPath">C:\Users\rokej\Downloads\collect-wsl-logs.ps1</S>
                <S N="InvocationName">Get-WindowsOptionalFeature</S>
                <I32 N="PipelineLength">0</I32>
                <I32 N="PipelinePosition">0</I32>
                <B N="ExpectingInput">false</B>
                <Obj N="CommandOrigin" RefId="10">
                  <TN RefId="10">
                    <T>System.Management.Automation.CommandOrigin</T>
                    <T>System.Enum</T>
                    <T>System.ValueType</T>
                    <T>System.Object</T>
                  </TN>
                  <ToString>Internal</ToString>
                  <I32>1</I32>
                </Obj>
                <Nil N="DisplayScriptPosition" />
              </Props>
            </Obj>
            <I32 N="ErrorCategory_Category">0</I32>
            <S N="ErrorCategory_Activity">Get-WindowsOptionalFeature</S>
            <S N="ErrorCategory_Reason">COMException</S>
            <S N="ErrorCategory_TargetName"></S>
            <S N="ErrorCategory_TargetType"></S>
            <S N="ErrorCategory_Message">NotSpecified: (:) [Get-WindowsOptionalFeature], COMException</S>
            <B N="SerializeExtendedInfo">false</B>
            <S N="ErrorDetails_ScriptStackTrace">at &lt;ScriptBlock&gt;, C:\Users\rokej\Downloads\collect-wsl-logs.ps1: line 57_x000D__x000A_at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 1</S>
          </MS>
        </Obj>
      </Objs>

    Footnotes

    1. github.com/PowerShell/PowerShell/discussions/25729#discussioncomment-13671569 ↩

  5. beedell-roke commented on Aug 7, 2025

    @beedell-roke
    Author

    Perhaps, this is a failure of PowerShell, per PowerShell/issues/25835.

  6. OneBlue commented on Oct 17, 2025

    @OneBlue
    Collaborator

    Hmm that's interesting. I've never seen that before. It's looking like the optional component logic causing this.

    What's the output of Get-WindowsOptionalFeature -Online ?

  7. OneBlue commented on Oct 17, 2025

    @OneBlue
    Collaborator

    Actually looks like this is tracked from powershell PowerShell/PowerShell#25835. Closing since the issue isn't coming from WSL

  8. beedell-roke commented on Oct 17, 2025

    @beedell-roke
    Author

    #issuecomment-3413532850

    Blue (@OneBlue), thanks. However, this isn't a downstream duplicate; I left this problem open because whilst upstream's problem remains, the WSL team should modify the affected script to not invoke via PowerShell Core, or, better yet, return an error message that it needs to be invoked on Windows PowerShell, if those modules fail with that error.

    I'll re-scope this issue if you agree.

    #event-20332812399

    Otherwise, please re-close as a duplicate, rather than as completed; it provides a better indicator of severity at the linked upstream issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions