PowerShell / PSResourceGet

PSResourceGet is the package manager for PowerShell
https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet
MIT License
483 stars 92 forks source link

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

Open mklement0 opened 7 months ago

mklement0 commented 7 months ago

Prerequisites

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:

Error details

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