Error when Using PowerShellGet Find-Module or Install-Module with the Name Parameter and a Local NuGet Repository

If you're following me on Twitter then you probably know that I've been working a lot with the new features in PowerShell version 5, with my focus being on the cmdlets in the OneGet and PowerShellGet modules.

I've been fighting an issue where an error is received when the Name parameter is specified with Find-Module or Install-Module when using a local NuGet Repository:

052814-1.jpg

1Find-PSGetExtModule : Module ‘Pscx’ was not found in the Gallery.
2At C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerShellGet\PSGet.psm1:72 char:13
3+ Find-PSGetExtModule -Name $Name `
4+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
5+ CategoryInfo : InvalidOperation: (:) [Write-Error], WriteErrorException
6+ FullyQualifiedErrorId : ModuleNotFound,Find-PSGetExtModule

I can also tell you this isn't an issue that's specific to a NuGet repository that's created with ProGet because I started out with a NuGet repository that was created with Visual Studio:

052814-2.jpg

The strange thing is this works without issue with the default online repository:

052814-3.jpg

To confirm that it wasn't an issue for just me I contacted Tore Groneng via twitter since I knew he had recently written a blog article about setting up an internal PowerShellGet repository with ProGet. He tested the issue I was experiencing and confirmed it was a problem for him as well.

As stated in the error message, I headed to line 72, character 13 of the file: C:\Windows\system32\WindowsPowerShell\v1.0\Modules\PowerShellGet\PSGet.psm1

052814-4.jpg

That led me to the Find-PSGetExtModule function in the PSGallery module which is located in a sub-directory of the PowerShellGet module:

052814-5.jpg

I tested the code down to line 298 and determined the problem exists on line 293:

052814-6.jpg

When the code on line 298 is run, the following command is executed in the example where I received the error:

052814-7a.jpg

I'm really not sure what the id: on line 293 does since I couldn't find it in any of the documentation for NuGet.exe, but simply removing it returns the expected results:

052814-8.jpg

I then removed id: from line 293 of the PSGallery module (this required some changes to the NTFS permissions of the file itself):

052814-9.jpg

After re-importing the PowerShellGet module, the Name parameter worked without issue:

052814-10.jpg

It also still works with the default online repository as well so there must be something where it parses the id: out somehow that is specific to the online repository:

052814-11.jpg

Note: PowerShell version 5 is currently in preview and shouldn't be installed in a production environment. Normally the Microsoft supplied modules aren't script modules so they're not modifiable and even though this one is, modification of the native modules is definitely not recommended and could lead to unexpected results to say the least.

Update:

I verified with Steve Murawski that there is already a Connect Bug for the same issue. Steve also provided me with a link to the NuGet documentation for the "id:" parameter.

µ