Skip to content

Find-PSResource stops searching, when one of registered repositories is not available. #1923

@peetrike

Description

@peetrike

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

When there are several repositories registered and one of them is currently not available (for example private repository when machine is out of office), then Find-PSResource stops with terminating error and refuses to search from available repositories.

Expected behavior

PS ❯ Find-PSResource sqlserver

Name      Version  Prerelease Repository Description
----      -------  ---------- ---------- -----------
SqlServer 22.4.5.1            PSGallery  This module allows SQL Server developers, administrators and business intelligence professionals to au…

Actual behavior

PS ❯ Find-PSResource sqlserver -ErrorAction Ignore
Find-PSResource: The network path was not found. : '\\server\share\folder'.

Error details

Exception             :
    Type       : System.IO.IOException
    TargetSite :
        Name          : Init
        DeclaringType : [System.IO.Enumeration.FileSystemEnumerator`1[TResult]]
        MemberType    : Method
        Module        : System.Private.CoreLib.dll
    Message    : The network path was not found. : '\\server\share\folder'.
    Source     : System.Private.CoreLib
    HResult    : -2147024843
    StackTrace :
   at System.IO.Enumeration.FileSystemEnumerator`1.Init()
   at System.IO.Enumeration.FileSystemEnumerableFactory.UserFiles(String directory, String expression, EnumerationOptions options)
   at System.IO.Directory.InternalEnumeratePaths(String path, String searchPattern, SearchTarget searchTarget, EnumerationOptions options)
   at System.IO.Directory.GetFiles(String path, String searchPattern, EnumerationOptions enumerationOptions)
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.LocalServerAPICalls.FindNameHelper(String packageName, String[] tags, Boolean includePrerelease
, ResourceType type, ErrorRecord& errRecord) in C:\__w\1\s\PSResourceGet\src\code\LocalServerApiCalls.cs:line 266
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.LocalServerAPICalls.FindName(String packageName, Boolean includePrerelease, ResourceType type,
ErrorRecord& errRecord) in C:\__w\1\s\PSResourceGet\src\code\LocalServerApiCalls.cs:line 109
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.SearchByNames(ServerApiCall currentServer, ResponseUtil currentResponseUtil, PSRepos
itoryInfo repository, Boolean shouldReportErrorForEachRepo)+MoveNext() in C:\__w\1\s\PSResourceGet\src\code\FindHelper.cs:line 792
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindHelper.FindByResourceName(String[] name, ResourceType type, VersionRange versionRange, NuGe
tVersion nugetVersion, VersionType versionType, String version, Boolean prerelease, String[] tag, String[] repository, Boolean includeDependenci
es, Boolean suppressErrors)+MoveNext() in C:\__w\1\s\PSResourceGet\src\code\FindHelper.cs:line 223
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource.ProcessResourceNameParameterSet() in C:\__w\1\s\PSResourceGet\src\code\FindPSRes
ource.cs:line 249
   at Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource.ProcessRecord() in C:\__w\1\s\PSResourceGet\src\code\FindPSResource.cs:line 148
   at System.Management.Automation.CommandProcessor.ProcessRecord()
CategoryInfo          : NotSpecified: (:) [Find-PSResource], IOException
FullyQualifiedErrorId : System.IO.IOException,Microsoft.PowerShell.PSResourceGet.Cmdlets.FindPSResource
InvocationInfo        :
    MyCommand        : Find-PSResource
    ScriptLineNumber : 1
    OffsetInLine     : 1
    HistoryId        : 13
    Line             : find-psresource sqlserver
    Statement        : find-psresource sqlserver
    PositionMessage  : At line:1 char:1
                       + find-psresource sqlserver
                       + ~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : find-psresource
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

PowerShell: 5.1 and 7.5.4
PSResourceGet: 1.1.1

Visuals

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions