Skip to content
This repository was archived by the owner on Jun 13, 2024. It is now read-only.
This repository was archived by the owner on Jun 13, 2024. It is now read-only.

Get-PSRepository, Install-Module, Get-InstalledModule do not consistently work when executed under 2 different windows accounts #669

@tristanbarcelon

Description

@tristanbarcelon

Steps to reproduce

$NugetMetadata = Get-InstalledModule -Name NugetMetadata -ErrorAction SilentlyContinue

if ($null -eq $NugetMetadata)
{
    Install-Module -Name NugetMetadata -Repository PSGallery -Scope CurrentUser -AllowClobber
}
else
{
    Import-Module -Name NugetMetadata
}

Expected behavior

if NugetMetadata module is not presently installed in user's scope, then install it from PSGallery repo. Unfortunately, even Get-PSRepository does not work and I'm presented with this error: WARNING: Unable to find module repositories.

Actual behavior

I get this error instead

WARNING: The property 'Values' cannot be found on this object. Verify that the property exists.
WARNING: The property 'Keys' cannot be found on this object. Verify that the property exists.
WARNING: Exception calling "Deserialize" with "1" argument(s): "'.', hexadecimal value 0x00, is an invalid character. Line 1, position 1."
Get-PackageSource: Unable to find repository 'PSGallery'. Use Get-PSRepository to see all available repositories.

Environment data

$PSVersionTable output

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

Get-Module -ListAvailable PowershellGet, PackageManagement output

    Directory: C:\program files\powershell\7\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Script     1.4.7                 PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     2.2.5                 PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability…}

    Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version    PreRelease Name                                PSEdition ExportedCommands
---------- -------    ---------- ----                                --------- ----------------
Binary     1.0.0.1               PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource…}
Script     1.0.0.1               PowerShellGet                       Desk      {Install-Module, Find-Module, Save-Module, Update-Module…}

Get-PackageProvider -ListAvailable output

Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            2.2.5.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Comma…
PowerShellGet            1.0.0.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions