Skip to content

[Find-PSResource] System.InvalidOperationException when i try to a version of an unlisted package #1383

Closed
@LaurentDardenne

Description

@LaurentDardenne

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 try to get an version of an unlisted package :

Find-psresource PnP.PowerShell -Version '1.10.22-nightly' -Prerelease -Repository PSGallery
#System.InvalidOperationException


Find-module PnP.PowerShell -RequiredVersion '1.10.22-nightly' -AllowPrerelease

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
1.10.22-nightly      PnP.PowerShell                      PSGallery            Microsoft 365 Patterns and Practices P...

Save-psresource PnP.PowerShell -Version '1.10.22-nightly' -Repository PSGallery -Path C:\temp\CacheTemp\
save-psresource : Package(s) 'PnP.PowerShell' could not be installed from repository 'PSGallery'.
Au caractère Ligne:1 : 1
+ save-psresource PnP.PowerShell -Version '1.10.22-nightly' -Repository ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (Microsoft.Power...s.InstallHelper:InstallHelper) [Save-PSResource], Resou
   rceNotFoundException
    + FullyQualifiedErrorId : InstallPackageFailure,Microsoft.PowerShell.PSResourceGet.Cmdlets.SavePSResource

Expected behavior

No result or the display of an understandable error message.

See : 
https://learn.microsoft.com/en-us/powershell/gallery/how-to/publishing-packages/deleting-packages?view=powershellget-2.x

Actual behavior

Find-psresource PnP.PowerShell -Version '1.10.22-nightly' -Prerelease -Repository PSGallery
Find-psresource : La séquence ne contient aucun élément.
Au caractère Ligne:1 : 1
+ find-psresource PnP.PowerShell -Version '1.10.22-nightly' -Prerelease ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Find-PSResource], InvalidOperationException
    + FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResour
   ce

Error details

$error[0]|select *

PSMessageDetails      :
Exception             : System.InvalidOperationException: La séquence ne contient aucun élément.
                           à System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
                           à Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.<SearchByNames>d__19.MoveNext()
                           à Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.<FindByResourceName>d__16.MoveNext()
                           à
                        Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource.ProcessResourceNameParameterSet()
                           à System.Management.Automation.CommandProcessor.ProcessRecord()
TargetObject          :
CategoryInfo          : NotSpecified: (:) [Find-PSResource], InvalidOperationException
FullyQualifiedErrorId : System.InvalidOperationException,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : à <ScriptBlock>, <Aucun fichier> : ligne 1
PipelineIterationInfo : {}


$StackTrace
   à System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   à Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.<SearchByNames>d__19.MoveNext()
   à Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.<FindByResourceName>d__16.MoveNext()
   à Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource.ProcessResourceNameParameterSet()
   à System.Management.Automation.CommandProcessor.ProcessRecord()

Environment data

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     0.5.24     Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceR...

Key   : PSVersion
Value : 5.1.19041.3031
Name  : PSVersion


Key   : PSEdition
Value : Desktop
Name  : PSEdition


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.19041.3031}
Name  : PSCompatibleVersions


Key   : BuildVersion
Value : 10.0.19041.3031
Name  : BuildVersion


Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion

Visuals

image

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions