Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
3 tasks done
mklement0 opened this issue Jan 24, 2024 · 0 comments
Open
3 tasks done

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

mklement0 opened this issue Jan 24, 2024 · 0 comments
Labels
Area-Install Issue-Bug Something isn't working

Comments

@mklement0
Copy link

mklement0 commented Jan 24, 2024

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

@mklement0 mklement0 changed the title -WhatIf results in extra, unwanted output -WhatIf results in extra, unwanted output and a spurious error Jan 24, 2024
@SydneyhSmith SydneyhSmith added Issue-Bug Something isn't working Area-Install and removed Needs-Triage labels Jan 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Install Issue-Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants