PowerShell / PowerShell/PSResourceGet

All commands returned `CommandNotFoundException` until `Get-Command -Module Microsoft.WinGet.Client` had been invoked.

Open
#1,826 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Needs-Attention :wave:
Dominant language
C#
Stars
576
Forks
114
Avg merge
1d 2h
Merged PRs (30d)
7

Description

Prerequisites
  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.
Steps to reproduce

I was unable to invoke any of the commands listed by Get-Command -Module Microsoft.WinGet.Client ^1 until I invoked that command. As an example, Get-WinGetPackage returned the undermentioned Error XML.

Expected behavior

$? should have returned $True after before invoking Get-Module Microsoft.PowerShell.PSResourceGet.

Actual behavior

It returned $False until I'd invoked Get-Module Microsoft.PowerShell.PSResourceGet.

Error 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 term 'Get-WinGetPackage' is not recognized as a name of a cmdlet, function, script file, or executable program._x000D__x000A_Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</ToString>
    <MS>
      <Obj N="Exception" RefId="1">
        <TN RefId="1">
          <T>System.Management.Automation.CommandNotFoundException</T>
          <T>System.Management.Automation.RuntimeException</T>
          <T>System.SystemException</T>
          <T>System.Exception</T>
          <T>System.Object</T>
        </TN>
        <ToString>System.Management.Automation.CommandNotFoundException: The term 'Get-WinGetPackage' is not recognized as a name of a cmdlet, function, script file, or executable program._x000D__x000A_Check the spelling of the name, or if a path was included, verify that the path is correct and try again._x000D__x000A_   at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)_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="ErrorRecord">The term 'Get-WinGetPackage' is not recognized as a name of a cmdlet, function, script file, or executable program._x000D__x000A_Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</S>
          <S N="CommandName">Get-WinGetPackage</S>
          <B N="WasThrownFromThrowStatement">false</B>
          <S N="TargetSite">System.Management.Automation.CommandInfo LookupCommandInfo(System.String, System.Management.Automation.CommandTypes, System.Management.Automation.SearchResolutionOptions, System.Management.Automation.CommandOrigin, System.Management.Automation.ExecutionContext)</S>
          <S N="Message">The term 'Get-WinGetPackage' is not recognized as a name of a cmdlet, function, script file, or executable program._x000D__x000A_Check the spelling of the name, or if a path was included, verify that the path is correct and try again.</S>
          <Obj N="Data" RefId="2">
            <TN RefId="2">
              <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="3">
                  <TN RefId="3">
                    <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.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)_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">Get-WinGetPackage</S>
      <S N="FullyQualifiedErrorId">CommandNotFoundException</S>
      <Obj N="InvocationInfo" RefId="4">
        <TN RefId="4">
          <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="5">
            <TN RefId="5">
              <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="6">
            <TN RefId="6">
              <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">1</I32>
          <I64 N="HistoryId">11</I64>
          <S N="ScriptName"></S>
          <S N="Line">Get-WinGetPackage</S>
          <S N="Statement">Get-WinGetPackage</S>
          <S N="PositionMessage">At line:1 char:1_x000D__x000A_+ Get-WinGetPackage_x000D__x000A_+ ~~~~~~~~~~~~~~~~~</S>
          <S N="PSScriptRoot"></S>
          <Nil N="PSCommandPath" />
          <S N="InvocationName">Get-WinGetPackage</S>
          <I32 N="PipelineLength">0</I32>
          <I32 N="PipelinePosition">0</I32>
          <B N="ExpectingInput">false</B>
          <Obj N="CommandOrigin" RefId="7">
            <TN RefId="7">
              <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">13</I32>
      <S N="ErrorCategory_Activity"></S>
      <S N="ErrorCategory_Reason">CommandNotFoundException</S>
      <S N="ErrorCategory_TargetName">Get-WinGetPackage</S>
      <S N="ErrorCategory_TargetType">String</S>
      <S N="ErrorCategory_Message">ObjectNotFound: (Get-WinGetPackage:String) [], CommandNotFoundException</S>
      <B N="SerializeExtendedInfo">false</B>
      <S N="ErrorDetails_ScriptStackTrace">at &lt;ScriptBlock&gt;, &lt;No file&gt;: line 1</S>
    </MS>
  </Obj>
</Objs>
Environment data

Get-Module Microsoft.PowerShell.PSResourceGet returns $Null, but $PSVersionTable returns:

PSVersion                 : 7.6.0-preview.4
PSEdition                 : Core
GitCommitId               : 7.6.0-preview.4
OS                        : Microsoft Windows 10.0.26120
Platform                  : Win32NT
PSCompatibleVersions      : {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion : 2.3
SerializationVersion      : 1.1.0.1
WSManStackVersion         : 3.0
Visuals

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the issue with Get-WinGetPackage, Get-Command -Module Microsoft.WinGet.Client, and Get-Module Microsoft.PowerShell.PSResourceGet on the reported PowerShell and Windows versions. Trace why the commands are unavailable before module discovery or invocation; done means the commands work without first running Get-Command or Get-Module.

Written by the indexing model from the issue text.

Assessment

Tech stack
powershell
Domain
cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.