Index
- The property ‘Name’ cannot be found on this object. Verify that the property exists.
- So how do we fix this?
- Conclusion
The property ‘Name’ cannot be found on this object. Verify that the property exists.
It was that time again, a co-worker sent me an e-mail asking if I could have a look at why a script was not working.
This script that my co-worker ran is in our RMM and uses custom modules that we host on our own internal repository and to get those modules we obviously have to connect to that repository. As I noticed several of the monitors in our RMM on that perticular device not working I realised the modules were missing and in fact the entire repository was missing from the device’s configuration. Testing manually gave me the error below.
PackageManagement\Register-PackageSource : The property 'Name' cannot be found
on this object. Verify that the property exists.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet.2.5\PSModule.psm1
:11587 char:17
+ ... $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Microsoft.Power...erPackageSource
:RegisterPackageSource) [Register-PackageSource], Exception
+ FullyQualifiedErrorId : PropertyNotFoundStrict,Microsoft.PowerShell.Pack
ageManagement.Cmdlets.RegisterPackageSource
A quick google proved that this was a common thing as there where a lot of posts on forums about this issue.
So I thought it would be good to write a blog about this, partly so I could use it as a reference for myself but also to help you, our readers, should you run into the same issue.
So how do we fix this?
In the example above you can see the error occurs with the 2.2.5 version of the module, wich at the time of writing is the latest version.
Suggestion 1
One suggestion is to reset the configuration by running Register-PSRepository -Default
. This should reset the configuration.
Problem is that this does not always do the trick.
Suggestion 2
Another suggestion that I found was to delete the config file. The file we are looking for is $env:LOCALAPPDATA\Microsoft\Windows\PowerShell\PowerShellGet\PSRepositories.xml
.
If you are haveing issues when running under the LocalSystem
account, the location is: C:\Windows\System32\config\systemprofile\AppData\Local
Just delete it and try again. And again, the same applies here, it does not always work.
Suggestion 3
Fortunately there is another option, one that seems to work the best (atleast from my experience).
Simply update the module! Well…. if it was just that easy…
The PowerShellGet module version that is shipped with Windows 11 is version 1.0.0.1 as I said earlier, I saw this issue with version 2.2.5 aswell. The reason for that being that Update-Module -Name PowerShellGet
does not work for version 1.0.0.1 as it is not installed through the PSGallery. So instead of Update-Module
I ran Install-Module -Name PowerShellGet
. After trying again, and again not having any success I decided to remove the old version, but that also cannot be done with a cmdlet (such as Uninstall-Module
). So I checked the location of the module and renamed the folder for 1.0.0.1
to _1.0.0.1
wich is located in C:\Program Files\WindowsPowerShell\Modules\PowerShellGet
and tried again. Finally success!
Conclusion
While I have found and tested only 3 solutions with the last one being succesfull there may be other solutions out there aswell.
If I find anything I will update this post with it.
This bug has been in PowerShell for quite some time now, and it does not seem like Microsoft will fix it anytime soon.
The issue is still open on Github with no real resoltion expected anytime soon.
But to be fair; how could they fix it? From my point of view one solution would be to force an update of the module and delete the old version through a Windows Update. But this could break things. Another solution would be to just start shipping the latest release of the module with Windows. That way at least in the future the issue will no longer occur. Anyway, I hope that this post will help you understand and resolve the issue should you run into this.
Leave a Reply