Skip to content

Set-PSResourceRepository does not accept pipeline input from Get-PSResourceRepository #670

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

Closed
3 tasks done
ThomasNieto opened this issue Jun 8, 2022 · 0 comments · Fixed by #705
Closed
3 tasks done

Comments

@ThomasNieto
Copy link
Contributor

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 cannot pipe the output from Get-PSResouceRepository to Set-PSResourceRepository. The error message that is thrown is also not something that I would expect. This issue can be fixed by adding ValueFromPipelineByPropertyName on the Name parameter.

Expected behavior

PS /> Get-PSResourceRepository | Set-PSResourceRepository -Trusted

Actual behavior

PS /> Get-PSResourceRepository | Set-PSResourceRepository -Trusted
Set-PSResourceRepository: Updating to repository store failed: Cannot find the repository because it does not exist. Try registering the repository using 'Register-PSResourceRepository'
PS /> Get-PSResourceRepository

Name      Uri                                      Trusted Priority
----      ---                                      ------- --------
PSGallery https://www.powershellgallery.com/api/v2 False   50

PS /> Set-PSResourceRepository -Name PSGallery -Trusted

Error details

PS /> Get-Error

Exception             :
    Type        : System.Management.Automation.PSInvalidOperationException
    ErrorRecord :
        Exception             :
            Type    : System.Management.Automation.ParentContainsErrorRecordException
            Message : Updating to repository store failed: Cannot find the repository because it does not exist. Try registering the reposi
tory using 'Register-PSResourceRepository'
            HResult : -2146233087
        CategoryInfo          : InvalidOperation: (:) [], ParentContainsErrorRecordException
        FullyQualifiedErrorId : InvalidOperation
    TargetSite  :
        Name          : ThrowTerminatingError
        DeclaringType : System.Management.Automation.MshCommandRuntime, System.Management.Automation, Version=7.2.4.500, Culture=neutral, PublicKe
yToken=31bf3856ad364e35
        MemberType    : Method
        Module        : System.Management.Automation.dll
    Message     : Updating to repository store failed: Cannot find the repository because it does not exist. Try registering the repository
 using 'Register-PSResourceRepository'
    Source      : System.Management.Automation
    HResult     : -2146233079
    StackTrace  :
   at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
TargetObject          : Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository
CategoryInfo          : InvalidArgument: (Microsoft.PowerShel…SResourceRepository:SetPSResourceRepository) [Set-PSResourceRepository], PSInvalidOp
erationException
FullyQualifiedErrorId : ErrorInNameParameterSet,Microsoft.PowerShell.PowerShellGet.Cmdlets.SetPSResourceRepository
InvocationInfo        :
    MyCommand        : Set-PSResourceRepository
    ScriptLineNumber : 1
    OffsetInLine     : 28
    HistoryId        : 14
    Line             : Get-PSResourceRepository | Set-PSResourceRepository -Trusted
    PositionMessage  : At line:1 char:28
                       + Get-PSResourceRepository | Set-PSResourceRepository -Trusted
                       +                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Set-PSResourceRepository
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1

Environment data

PS /> Get-Module PowerShellGet

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     3.0.14     beta14     PowerShellGet

PS /> Get-Module PowerShellGet

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Binary     3.0.14     beta14     PowerShellGet

Visuals

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants