Skip to content
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

Import-PSGetRepository fails silently to import UNC based PowerShellGet v2 repositories on PowerShell 5.1 #1442

Closed
3 tasks done
kborowinski opened this issue Oct 11, 2023 · 4 comments · Fixed by #1460
Closed
3 tasks done

Comments

@kborowinski
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

Import-PSGetRepository fails silently to import UNC based PowerShellGet v2 repositories on PowerShell 5.1
(It works on PowerShell 7.3.8)

Steps to reproduce:

  1. Register an UNC PowerShellGet v2 repository (remote PC requried) on PowerShell 5.1:
Register-PSRepository -Name Test -SourceLocation \\Server\RepoPath -InstallationPolicy Trusted
  1. Try to import the PowerShellGet v2 repository:
Import-PSGetRepository -Verbose -Force
  1. The UNC repository is not imported:
Get-PSResourceRepository

Expected behavior

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.3.8
PSEdition                      Core
GitCommitId                    7.3.8
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

PS C:\> Register-PSRepository -Name PowerEdge -SourceLocation \\poweredge\transfer -InstallationPolicy Trusted
Package source with Name: PowerEdge added successfully.
PS C:\> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PowerEdge                 Trusted              \\poweredge\transfer
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2

PS C:\> Import-PSGetRepository -Verbose -Force
VERBOSE: Found 2 registered PowerShellGet repositories.
VERBOSE: Selected 1 NuGet repositories.
VERBOSE: Registering PowerEdge at \\poweredge\transfer -Trusted:$True -Force:$True.

Name      Uri                       Trusted Priority
----      ---                       ------- --------
PowerEdge file://poweredge/transfer True    50

PS C:\> Get-PSResourceRepository -Verbose

Name      Uri                                      Trusted Priority
----      ---                                      ------- --------
PowerEdge file://poweredge/transfer                True    50
PSGallery https://www.powershellgallery.com/api/v2 False   50

PS C:\>

Actual behavior

PS C:\> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

PS C:\> Register-PSRepository -Name PowerEdge -SourceLocation \\poweredge\transfer -InstallationPolicy Trusted
Package source with Name: PowerEdge added successfully.
PS C:\> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Trusted              https://www.powershellgallery.com/api/v2
PowerEdge                 Trusted              \\poweredge\transfer


PS C:\> Import-PSGetRepository -Verbose -Force
VERBOSE: Found 2 registered PowerShellGet repositories.
VERBOSE: Selected  NuGet repositories.
PS C:\> Get-PSResourceRepository -Verbose

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

PS C:\>

Error details

No error

Environment data

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0      Microsoft.PowerShell.PSResourceGet  {Find-PSResource, Get-InstalledPSResource, Get-PSResourceRepository, Get-PSScriptFileInfo...}



Name                           Value
----                           -----
PSVersion                      5.1.19041.3031
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.3031
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Visuals

No response

@SydneyhSmith
Copy link
Collaborator

thanks for reporting @kborowinski this needs investigation

@alerickson
Copy link
Member

alerickson commented Oct 21, 2023

I wasn't able to repro this. @kborowinski if you open the xml file here: %LocalAppData%\PSResourceGet\PSResourceRepository.xml do you only see the PSGallery registered? If so can you delete this file then try running Import-PSGetRepository -Verbose -Force again?

@kborowinski
Copy link
Contributor Author

kborowinski commented Oct 22, 2023

@alerickson:

  1. I see only the PSGallery registered:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <Repository Name="PSGallery" Url="https://www.powershellgallery.com/api/v2" APIVersion="v2" Priority="50" Trusted="false" />
</configuration>
  1. Deleting the file and executing Import-PSGetRepository -Verbose -Force does not help.

I must stress that this bug happens only on PowerShell 5.1, not on PowerShell 7.3.8 or higher. I've tried this on six different computers now, with the same results (two domain members and two standalone at work, and two at home)

Visuals:
Repository

As you can see in the verbose output of command Import-PSGetRepository -Verbose -Force on PowerShell 5.1, it looks like the cmdlet finds two repos but nothing gets registered -> Verbose: Selected NuGet repositories.:
image

On PowerShell 7.3.8 it looks like this:
image

And for completeness, visuals on the PowerShell 7.3.8:
Repository2

If you want me to do any more tests, will be glad to help!

@kborowinski
Copy link
Contributor Author

kborowinski commented Oct 25, 2023

@SydneyhSmith @alerickson OK, I've found the issue with Import-PSResourceGet on PowerShell 5.1. and will push a PR later today.

Edit:
I've missed your PR request, sorry. If I can suggest a slight change to the proposed PR as there is still a problem with verbose message on PowerShell 5.1

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.

3 participants