6

I'm getting below error when trying to run Register-PsRepository

I have tried:

  • re-installing WMF 5, PowerShellGet and PackageManagement modules
  • updating said modules
  • debugging PowerShellGet module I can see that PsBoundParameters does pass the Name value to Register-PackageSource command.
  • Register-PackageSource does work correctly when I run it manually.

Any Ideas?

PS C:\> Register-PSRepository -Name MyRepo -SourceLocation  https://MyRepo.com/api/Myrepo   -Credential $c
PackageManagement\Register-PackageSource : The property 'Name' cannot be 
found on this object. Verify that the property exists.
At C:\Program  Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:4631 char:17
Tomek
  • 641
  • 1
  • 6
  • 16

1 Answers1

9

Please check PSRepository configuration xml file:

%localappdata%\Microsoft\windows\PowerShell\PowerShellGet\PSRepositories.xml

It's possible that file is corrupt and that could lead to an error you are getting.

Lucas
  • 106
  • 2
  • Yes, Thank You Lukas! This file was corrupted, I have re-created the file - everything works like a charm ! – Tomek May 09 '18 at 10:25
  • You, saved my day, that was the problem indeed! In my case my code was running through DSC which is running under system account and the `PSRepository.xml` will be located under `C:\Windows\System32\config\systemprofile\AppData\Local\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml` – Alex Titarenko Feb 22 '21 at 23:48
  • Received a similar exception message (referencing `'Values'` instead of `'Name'` property in the message posted in the original question). Removal of this file resolved, with no manual recreate needed. – Bryan Jun 14 '22 at 20:45