PowerShell / PowerShell/PSResourceGet

`-WhatIf` results in extra, unwanted output and a spurious error

Open
#1,541 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Area-Install Issue-Bug
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
Install-PSResource Microsoft.PowerShell.PSResourceGet -WhatIf
Expected behavior

A what-if message describing what version would be installed only.

Actual behavior
What if: Performing the operation "Install-PSResource" on target "Package to install: 'Microsoft.PowerShell.PSResourceGet', version: '1.0.1'".
What if: Performing the operation "Install-PSResource" on target "Exit ShouldProcess".
Install-PSResource: Package(s) 'Microsoft.PowerShell.PSResourceGet' could not be installed from repository 'PSGallery'.

That is:

  • an extraneous 'What if:' line is printed
  • an error is unexpectedly reported aftewards


### Error details

```console
Exception             : 
    Type    : Microsoft.PowerShell.PSResourceGet.UtilClasses.ResourceNotFoundException
    Message : Package(s) 'Microsoft.PowerShell.PSResourceGet' could not be installed from repository 'PSGallery'.
    HResult : -2146233088
TargetObject          : Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
CategoryInfo          : InvalidData: (Microsoft.PowerShel…s.InstallPSResource:InstallPSResource) [Install-PSResource], ResourceNotFoundException
FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.InstallPSResource
InvocationInfo        : 
    MyCommand        : Install-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 18
    Line             : Install-PSResource Microsoft.PowerShell.PSResourceGet -WhatIf
    Statement        : Install-PSResource Microsoft.PowerShell.PSResourceGet -WhatIf
    PositionMessage  : At line:1 char:1
                       + Install-PSResource Microsoft.PowerShell.PSResourceGet -WhatIf
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Install-PSResource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
Environment data
PowerShell 7.4.1 on macOS 14.2.1, module version 1.2.5
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

Reproduce the issue with Install-PSResource Microsoft.PowerShell.PSResourceGet -WhatIf and start by tracing the Install-PSResource cmdlet's WhatIf or ShouldProcess handling. Done means the command emits only the expected version message and does not report the extra "Exit ShouldProcess" message or an installation error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, powershell
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.