GithubHelp home page GithubHelp logo

powershell / psresourceget Goto Github PK

View Code? Open in Web Editor NEW
481.0 27.0 92.0 8.1 MB

PSResourceGet is the package manager for PowerShell

Home Page: https://www.powershellgallery.com/packages/Microsoft.PowerShell.PSResourceGet

License: MIT License

PowerShell 37.35% C# 62.65%
powershellget packagemanagement powershell powershell-module psresourceget

psresourceget's Introduction

License Documentation - PSResourceGet PowerShell Gallery - PSResourceGet Minimum Supported PowerShell Version

Important Note

If you were familiar with the PowerShellGet 3.0 project, we renamed the module to be PSResourceGet, for more information please read this blog.

If you would like to open a PR please open an issue first so that necessary discussion can take place. Please open an issue for any feature requests, bug reports, or questions for PSResourceGet. Please note, the repository for PowerShellGet v2 is available at PowerShell/PowerShellGetv2. The repository for the PowerShellGet v3, the compatibility layer between PowerShellGet v2 and PSResourceGet, is available at PowerShell/PowerShellGet.

Introduction

PSResourceGet is a PowerShell module with commands for discovering, installing, updating and publishing the PowerShell resources like Modules, Scripts, and DSC Resources.

Documentation

Documentation for PSResourceGet is currently under its old name PowerShellGet v3, please Click here to reference the documentation.

Requirements

  • PowerShell 5.0 or higher.

Get PSResourceGet Module

Please use the PowerShell Gallery to get the latest version of the module.

Get PowerShellGet Source

Steps

  • Obtain the source

    git clone https://github.com/PowerShell/PSResourceGet
  • Navigate to the local repository directory

PS C:\> cd c:\Repos\PSResourceGet
PS C:\Repos\PSResourceGet>
  • Build the project
# Build for the net472 framework
PS C:\Repos\PSResourceGet> .\build.ps1 -Clean -Build -BuildConfiguration Debug -BuildFramework net472

# Build for the netstandard2.0 framework
PS C:\Repos\PSResourceGet> .\build.ps1 -Clean -Build -BuildConfiguration Debug -BuildFramework netstandard2.0
  • Publish the module to a local repository
PS C:\Repos\PSResourceGet> .\build.ps1 -Publish
  • Run functional tests
PS C:\Repos\PSResourceGet> Invoke-PSPackageProjectTest -Type Functional
  • Import the module into a new PowerShell session
# If running PowerShell 6+
C:\> Import-Module C:\Repos\PSResourceGet\out\PSResourceGet

# If running Windows PowerShell
C:\> Import-Module C:\Repos\PSResourceGet\out\PSResourceGet\PSResourceGet.psd1

Code of Conduct

Please see our Code of Conduct before participating in this project.

Security Policy

For any security issues, please see our Security Policy.

psresourceget's People

Contributors

adityapatwardhan avatar alerickson avatar alyssa1303 avatar anamnavi avatar andrewsuh98 avatar andyleejordan avatar antonyoni avatar cansuerdogan avatar conorc32 avatar dependabot[bot] avatar evelyn-bi avatar friedrichweinmann avatar fsackur avatar gerryleys avatar hemisphera avatar jameswtruher avatar jaykul avatar justingrote avatar kborowinski avatar keithallenjackson avatar nextgdata avatar o-l-a-v avatar paulhigin avatar sdwheeler avatar sean-r-williams avatar seeminglyscience avatar step-security-bot avatar stevel-msft avatar sydneyhsmith avatar thomasnieto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

psresourceget's Issues

Register-PSRepository raises errors about "invalid Web Uri", despite underlying httpclient recognizing the Uri and [Uri] parsing

I have a very simple problem I want to solve: Due to reasons beyond my control, the company I work for uses a ".local" domain name internally, for everything. My repository url is "http://packages.mycompany.local/nuget/Mycompany-Development/api/v2" - which according to Register-PSRepository is not a "Web Uri" (whatever the heck that means).

It appears this is a bogus error message, largely due to the sophisticated and overly complicated sanity checks Register-PSRepository tries to perform. I've extracted all the required sub-functions to replicate the behavior, modulo the final error trap that surfaces the wrong error.

function Get-LocationString
{
    [CmdletBinding(PositionalBinding=$false)]
    Param
    (
        [Parameter()]
        [Uri]
        $LocationUri
    )

    $LocationString = $null

    if($LocationUri)
    {
        if($LocationUri.Scheme -eq 'file')
        {
            $LocationString = $LocationUri.OriginalString
        }
        elseif($LocationUri.AbsoluteUri)
        {
            $LocationString = $LocationUri.AbsoluteUri
        }
        else
        {
            $LocationString = $LocationUri.ToString()
        }
    }

    return $LocationString
}

function Resolve-Location
{
    [CmdletBinding()]
    [OutputType([string])]
    Param
    (
        [Parameter(Mandatory=$true)]
        [string]
        $Location,

        [Parameter(Mandatory=$true)]
        [string]
        $LocationParameterName,

        [Parameter()]
        $Credential,

        [Parameter()]
        $Proxy,

        [Parameter()]
        $ProxyCredential,

        [Parameter()]
        [System.Management.Automation.PSCmdlet]
        $CallerPSCmdlet
    )

    # Ping and resolve the specified location
    if(-not (Test-WebUri -uri $Location))
    {
        if(Microsoft.PowerShell.Management\Test-Path -Path $Location)
        {
            return $Location
        }
        elseif($CallerPSCmdlet)
        {
            $message = $LocalizedData.PathNotFound -f ($Location)
            ThrowError -ExceptionName "System.ArgumentException" `
                       -ExceptionMessage $message `
                       -ErrorId "PathNotFound" `
                       -CallerPSCmdlet $CallerPSCmdlet `
                       -ErrorCategory InvalidArgument `
                       -ExceptionObject $Location
        }
    }
    else
    {
        $pingResult = Ping-Endpoint -Endpoint $Location -Credential $Credential -Proxy $Proxy -ProxyCredential $ProxyCredential
        $statusCode = $null
        $exception = $null
        $resolvedLocation = $null
        if($pingResult -and $pingResult.ContainsKey($Script:ResponseUri))
        {
            $resolvedLocation = $pingResult[$Script:ResponseUri]
        }

        if($pingResult -and $pingResult.ContainsKey($Script:StatusCode))
        {
            $statusCode = $pingResult[$Script:StatusCode]
        }

        Write-Debug -Message "Ping-Endpoint: location=$Location, statuscode=$statusCode, resolvedLocation=$resolvedLocation"

        if((($statusCode -eq 200) -or ($statusCode -eq 401)) -and $resolvedLocation)
        {
            return $resolvedLocation
        }
        elseif($CallerPSCmdlet)
        {
            $message = $LocalizedData.InvalidWebUri -f ($Location, $LocationParameterName)
            ThrowError -ExceptionName "System.ArgumentException" `
                       -ExceptionMessage $message `
                       -ErrorId "InvalidWebUri" `
                       -CallerPSCmdlet $CallerPSCmdlet `
                       -ErrorCategory InvalidArgument `
                       -ExceptionObject $Location
        }
    }
}

function Test-WebUri
{
    [CmdletBinding()]
    [OutputType([bool])]
    Param
    (
        [Parameter(Mandatory=$true)]
        [ValidateNotNullOrEmpty()]
        [Uri]
        $uri
    )

    return ($uri.AbsoluteURI -ne $null) -and ($uri.Scheme -match '[http|https]')
}

function Ping-Endpoint
{
    [CmdletBinding()]
    param
    (
        [Parameter()]
        [ValidateNotNullOrEmpty()]
        [string]
        $Endpoint,

        [Parameter()]
        $Credential,

        [Parameter()]
        $Proxy,

        [Parameter()]
        $ProxyCredential,

        [Parameter()]
        [switch]
        $AllowAutoRedirect = $true
    )

    $results = @{}

    $WebProxy = $null
    if($Proxy -and ('Microsoft.PowerShell.Commands.PowerShellGet.InternalWebProxy' -as [Type]))
    {
        $ProxyNetworkCredential = $null
        if($ProxyCredential)
        {
            $ProxyNetworkCredential = $ProxyCredential.GetNetworkCredential()
        }

        $WebProxy = New-Object Microsoft.PowerShell.Commands.PowerShellGet.InternalWebProxy -ArgumentList $Proxy,$ProxyNetworkCredential
    }

    if(HttpClientApisAvailable)
    {
        $response = $null
        try
        {
            $handler = New-Object System.Net.Http.HttpClientHandler

            if($Credential)
            {
                $handler.Credentials = $Credential.GetNetworkCredential()
            }
            else
            {
                $handler.UseDefaultCredentials = $true
            }

            if($WebProxy)
            {
                $handler.Proxy = $WebProxy
            }

            $httpClient = New-Object System.Net.Http.HttpClient -ArgumentList $handler
            $response = $httpclient.GetAsync($endpoint)
        }
        catch
        {
        }

        if ($response -ne $null -and $response.result -ne $null)
        {
            Write-Host $response.Result
            $results.Add($Script:ResponseUri,$response.Result.RequestMessage.RequestUri.AbsoluteUri.ToString())
            $results.Add($Script:StatusCode,$response.result.StatusCode.value__)
        }
    }
    else
    {
        $iss = [System.Management.Automation.Runspaces.InitialSessionState]::Create()
        $iss.types.clear()
        $iss.formats.clear()
        $iss.LanguageMode = "FullLanguage"

        $WebRequestcmd =  @'
            param($Credential, $WebProxy)
            try
            {{
                $request = [System.Net.WebRequest]::Create("{0}")
                $request.Method = 'GET'
                $request.Timeout = 30000
                if($Credential)
                {{
                    $request.Credentials = $Credential.GetNetworkCredential()
                }}
                else
                {{
                    $request.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
                }}
                $request.AllowAutoRedirect = ${1}
                if($WebProxy)
                {{
                    $request.Proxy = $WebProxy
                }}
                $response = [System.Net.HttpWebResponse]$request.GetResponse()
                if($response.StatusCode.value__ -eq 302)
                {{
                    $response.Headers["Location"].ToString()
                }}
                else
                {{
                    $response
                }}
                $response.Close()
            }}
            catch [System.Net.WebException]
            {{
                "Error:System.Net.WebException"
            }}
'@ -f $EndPoint, $AllowAutoRedirect

        $ps = [powershell]::Create($iss).AddScript($WebRequestcmd)

        if($WebProxy)
        {
            $null = $ps.AddParameter('WebProxy', $WebProxy)
        }

        if($Credential)
        {
            $null = $ps.AddParameter('Credential', $Credential)
        }

        $response = $ps.Invoke()
        $ps.dispose()
        if ($response -ne "Error:System.Net.WebException")
        {
            if($AllowAutoRedirect)
            {
                $results.Add($Script:ResponseUri,$response.ResponseUri.ToString())
                $results.Add($Script:StatusCode,$response.StatusCode.value__)
            }
            else
            {
                $results.Add($Script:ResponseUri,[String]$response)
            }
        }
    }
    return $results
}

function HttpClientApisAvailable
{
    $HttpClientApisAvailable = $false
    try
    {
        [System.Net.Http.HttpClient]
        $HttpClientApisAvailable = $true
    }
    catch
    {
    }
    return $HttpClientApisAvailable
}
$SourceLocation = [Uri] "http://packages.mycompany.local/nuget/Mycompany-Development/api/v2" 

# Ping and resolve the specified location
            $SourceLocation = Resolve-Location -Location (Get-LocationString -LocationUri $SourceLocation) `
                                               -LocationParameterName 'SourceLocation' `
                                               -Credential $Credential `
                                               -Proxy $Proxy `
                                               -ProxyCredential $ProxyCredential `
                                               -CallerPSCmdlet $PSCmdlet

I'm not 100% sure, but I think the issue is that Resolve-Location treats any failures as "Web Uri" failures, even though the error appears to be due to $Script:$ResponseUri not existing/being a null key. (I'm not a PowerShell expert and while I generally understand the concept of scope-modifiers, I generally program in C# where you can't dynamically change scopes. To a C# programmer, this looks like bad code or non-sensical code.)

This appears to be an issue since PowerShellGet was called OneGet: OneGet/TestBuild#2

In that issue, it appears that Ping-Endpoint was to blame. Oddly, this was 3 years ago and still not fixed as OneGet got renamed PowerShellGet.

Proposal: Allow multiple repositories to contain the same package

If you have 2 repositories registered, and both of them contain a package Foo, you get an error when you run Install-Module Foo, saying that you have to pick a repository.

It would be better IMHO if this was permitted, and PowerShellGet automatically picked a repository when this happened. The main question is: when 2 repositories contain the requested module, how are ties broken - ie, which one do we pick?

Suggestion:

When Install-Module is run, we find all candidate repositories which contain a matching module, as at present. Then we order them using the method below to pick the preferred repo.

First, trusted vs untrusted is used. All trusted repositories are automatically higher ranked than all untrusted repos.

Second, introduce an explicit ordering for repositories, and a way for users to reorder them. The PSRepositoryInfo flag would have a Priority property added, which would be an int value, with 0 as lowest priority (last to be picked). This can be null, if not explicitly configured, which is treated as 0. Priorities need not be unique or consecutive.

Users can set the Priority property at Register-PSRepository time, and with Set-PSRepository -Priority. If not specified they get 0 priority.

Third, if 2 repositories have the same trust status and the same priority (including null) we pick them in alphabetical order.

Get-PSRepository would display the repos in priority order, NOT the order of the ordered table they are stored in (which is sorted by key). Additionally, it would show the Priority field by default.

This should not be a breaking change, since it only updates behavior for situations which would previously have caused an error.

Questions:

What if a repo with lower priority contains a module with higher version? Should that be taken into account? I think no.

Is it confusing to display an untrusted repo with Priority 999 and a trusted one with priority 1, and then choose the trusted one first?

Should the behavior of any other commands change?

What about package management, any changes needed there?

Please add "Set-Module" and "Set-Script"

Hi !

Short reason:
When publishing to the PSGallery, iยดd like to set Module details, as i could do it in the WebUI.
Sure this is in the privatedata section, but a later change must be done in the console WebUI

Detailed Reason:
Real-world testing of modules and script means publish it to the gallery and then test (i.e. deployment to Azure automation, Pester, ... ).
If this is part of the CI/CD pipeline, it also means when a module/script has issues in testing weยดd like to hide it after it has been published programmatically.

So a Set-Module command would look like this:
Set-Module -Name 'mymodule' -visibility $false

R.

-AllowPrerelease should be allowed with wildcards in the name

I'm trying to find all modules in AzureRM that have preview modules, and what those versions are. I get this response:

Find-Module : The RequiredVersion, MinimumVersion, MaximumVersion, AllVersions or AllowPrerelease parameters are
allowed only when you specify a single name as the value of the Name parameter, without any wildcard characters.
At line:1 char:1
+ Find-Module -Name AzureRM.* -Repository PSGallery -AllowPrerelease |  ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Find-Module], ArgumentException
    + FullyQualifiedErrorId : VersionParametersAreAllowedOnlyWithSingleName,Find-Module

Not sure why this isn't supported... It doesn't seem like a scenario that should be excluded.

Publish-Module forces semantic versioning regardless of manifest version

If I have a module using 4 part versioning which ends in a 0 (1.2.0.0) that I try to publish using Publish-Module then it create a nupkg and nuspec with the version number 1.2.0 but leaves the manifest correct. After digging into the code and PowerShell/PowerShellGetv2#218 it looks like a problem with using dotnet.exe or a newer version of nuget.exe (3+). The initial nuspec file generated by the Publish-PSArtifactUtility function

If a manifest is using 4 part versioning then the nupkg and contained nuspec should reflect this regardless of which application was used to generate the nupkg.

This isn't a big problem for the PowerShell Gallery but some nuget providers are seeing both the nupkg version and the manifest version. Our internal ProGet instance is doing pass through to the PSGallery and it's showing two versions for any modules published like this, both 1.2.0.0 and 1.2.0, and this is causing further issues.

Save/Install-Script Uses ScriptSourceLocation instead of SourceLocation for Module Dependencies

Save-Script and Install-Script queries required modules from ScriptSourceLocation not SourceLocation repository.

Steps to reproduce

  1. Create a script that requires a module
  2. Store module and script on separate repositories
  3. Save or Install script
Get-PSRepository | Select-Object -Property *

Name                      : production
SourceLocation            : https://internalrepo/api/nuget/psmodule-production
Trusted                   : True
Registered                : True
InstallationPolicy        : Trusted
PackageManagementProvider : NuGet
PublishLocation           :
ScriptSourceLocation      : https://internalrepo/api/nuget/psscript-production
ScriptPublishLocation     :
ProviderOptions           : {}

Install-Script -Name Script1

Expected behavior

Save-Script and Install-Script should install/save module dependencies from SourceLocation and install/save script from ScriptSourceLocation without error.

Actual behavior

Install-Script tries to find Module1 in psscript-production repository instead of psmodule-production.

PS C:\> Install-Script Script1 -Verbose
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://internalrepo/api/nuget/psscript-production' and PackageManagementProvider is 'NuGet'.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Script1'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'Script1'.
VERBOSE: Performing the operation "Install-Script" on target "Version '1.0.0' of script 'Script1'".
VERBOSE: The installation scope is specified to be 'AllUsers'.
VERBOSE: The specified script will be installed in 'C:\Program Files\WindowsPowerShell\Scripts' and its dependent modules will be installed in 'C:\Program Files\WindowsPowerShell\Modules'.
VERBOSE: The specified Location is 'NuGet' and PackageManagementProvider is 'NuGet'.
VERBOSE: Downloading script 'Script1' with version '1.0.0' from the repository 'https://internalrepo/api/nuget/psscript-production'.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Script1'' for ''.
VERBOSE: Searching repository 'https://internalrepo/api/nuget/psscript-production/FindPackagesById()?id='Module1'' for ''.
PackageManagement\Install-Package : Unable to find dependent script(s) (Module1)
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.0.4\PSModule.psm1:9637 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Module1:String) [Install-Package], Exception
    + FullyQualifiedErrorId : UnableToFindDependencyPackage,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Environment data

> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.14409.1018
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14409.1018
CLRVersion                     4.0.30319.36470
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
> Get-Module -ListAvailable PowerShellGet,PackageManagement

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.2.4      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     2.0.4      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     2.0.3      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     2.0.1      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.208
NuGet                    3.0.0.1          Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            2.0.4.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, Ac...
PowerShellGet            2.0.3.0
PowerShellGet            2.0.1.0
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Please, just install the module when I ask!

Using PowerShellGet in deployments or DSC environments is entirely too complicated and failure prone.

Expected Behavior

Install-Module $MyModuleName -Source $MyPrivateFeed

Should automatically ensure I have the latest version of the module (in much the same way it would do if I was installing $MyOtherModule and $MyModuleName was just a dependency). It shouldn't care if the module is not installed, has an old version, or was previously installed by hand -- it just needs to get the latest version installed if it's not already. And if it is already, it should just return successfully!

Actual Behavior

First, we must successfully (re)register the repository, because we can't specify it by URL (see PowerShell/PowerShellGet#28)

Then, we must preinstall nuget -- even though we don't actually care about nuget nor want to know anything about it. Since Install-Module inexplicably doesn't support automatic bootstrapping without prompting, we have to jump through extra hoops (see PowerShell/PowerShellGetv2#101)

Finally, we can try to install our modules. But I don't know if this is a first time install, or an upgrade -- so I can't just call Install-Module because it may throw any number of different exceptions if the module is already installed (it's not smart enough to just Update instead, even though it knows that's what's needed). Particularly, if this machine has been handled by other users, there may be cmdlet collisions, and there may even be another module with the same name installed (perhaps not through PowerShellGet), and it might even have a publisher file ...

This is what I have (note the repetitive use of -Credential because I am using a VSTS private repository for some things):

try {
    # If the module is already installed, use Update, otherwise use Install
    if ([bool](Get-Module $MyModuleName -ListAvailable)){
         Update-Module $MyModuleName -Credential $Credential -ErrorAction Stop
    } else {
         Install-Module $MyModuleName -Repository $MyRepoName -Scope AllUsers -Credential $Credential -ErrorAction Stop
    }
} catch {
    # But if something went wrong, just -Force it, hard.
    Install-Module $MyModuleName -Repository $MyRepoName -Scope AllUsers -Credential $Credential -Force -SkipPublisherCheck -AllowClobber
}

Of course, depending on the module, and how it was previously installed ... even that may fail, so I need to also add the -SkipPublisherCheck -AllowClobber parameters and so on.

The only reason I don't resort to the full -Force treatment in the first place is that I'm trying to be a good citizen and avoid re-downloading and reinstalling the module if it's already installed (since PowerShellGet doesn't seem to use nuget's machine cache, even though it does apparently need nuget installed...).

And one final point: what I really want is to register the feeds (and their credentials) in DSC at the machine level -- so I don't have to deal with the feed stuff (and the credential stuff) when it's time to install or upgrade software.

Possible Solution

  1. Accept URLs for the repository like Install-Package does
  2. Credentials should be stored with the feed registration
  3. -FORCE should mean ... figure it out and just get it installed.

I shouldn't have to say -Force three different ways, and I shouldn't have to call Update instead of Install to get the right behavior when the module is already installed.

Install-Module fails saying root module not found when actually one of dependencies is not found

Expected Behavior

When PowerShellGet cannot find one of the module dependencies, it should state the name of the dependency it cannot find.

Current Behavior

It states that it can't find the root module, even when it can.

Possible Solution

Have the error message say the name of the dependency it could not find.

Steps to Reproduce (for bugs)

PS C:\WINDOWS\system32> Find-Module VMware.PowerCLI -Repository PSGallery -RequiredVersion 10.2.0.9372002

Version              Name                                Repository           Description
-------              ----                                ----------           -----------
10.2.0.9372002       VMware.PowerCLI                     PSGallery            This Windows PowerShell module contain...


PS C:\WINDOWS\system32> Install-Module VMware.PowerCLI -Repository PSGallery -RequiredVersion 10.2.0.9372002 -WhatIf
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'VMware.PowerCLI'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.6\PSModule.psm1:9455 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\WINDOWS\system32> Install-Module VMware.PowerCLI -Repository PSGallery -RequiredVersion 10.2.0.9372002 -WhatIf -Verbose
VERBOSE: Suppressed Verbose Repository details, Name = 'PSGallery', Location =
'https://www.powershellgallery.com/api/v2/'; IsTrusted = 'False'; IsRegistered = 'True'.
VERBOSE: Repository details, Name = 'PSGallery', Location = 'https://www.powershellgallery.com/api/v2/'; IsTrusted =
'False'; IsRegistered = 'True'.
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='VMware.PowerCLI'' for
''.
VERBOSE: Total package yield:'1' for the specified package 'VMware.PowerCLI'.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='VMware.VimAutomation.Sdk'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'VMware.VimAutomation.Sdk'.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='VMware.VimAutomation.Common'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'VMware.VimAutomation.Common'.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository
'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='VMware.VimAutomation.Sdk'' for ''.
VERBOSE: Total package yield:'1' for the specified package 'VMware.VimAutomation.Sdk'.
VERBOSE: Using the specified source names : 'PSGallery'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is
'NuGet'.
VERBOSE: Searching repository 'https://www.powershellgallery.com/api/v2/FindPackagesById()?id='VMware.Vim'' for ''.
VERBOSE: Total package yield:'0' for the specified package 'VMware.Vim'.
PackageManagement\Install-Package : No match was found for the specified search criteria and module name
'VMware.PowerCLI'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.6\PSModule.psm1:9455 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Ex
   ception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Context

This is causing incorrect and misleading error messages in our Gallery security scan output.

Your Environment

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      5.1.17134.228
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.17134.228
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

> Get-Module
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     1.1.7.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-Pack...
Script     1.6.6      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCap...
Script     2.0.0      PSReadline                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...

> Get-Module -ListAvailable PowerShellGet,PackageManagement
    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.6.6      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCap...

> Get-PackageProvider
Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.6.6.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.208
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.6.6.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Improvement: Update 'Install-Module' cmdlet to install from any PSRepository when duplicate PSModules are present

Expected Behavior (Option 1)

There would be an additional switch (e.g. -AllowDuplicates) that could be specified on the Install-Module cmdlet call. The intent of this would be that this would prevent the cmdlet from raising an error/exception if there are the same versions of the same PSModule on multiple PSRepositories registered on a machine.

If there are multiple, registered PSRepositories on a machine (e.g. PSRepo1, PSRepo2, PSRepo3) that all (or at least two) have the same version of a PSModule (e.g. PSModuleXYZ), then when using/calling the Install-Module function without specifying any -Repository parameter value, but with specifing another switch (e.g. `-AllowDuplicates'), like so...

Install-Module 'PSModuleXYZ' -AllowDuplicates

... this should install the PSModuleXYZ PSModule, rather than raising an error that the same version exists in multiple repositories.

In a similar way, specifying multiple repositories (rather than none) should also install the PSModule from any of the repositories that has it (rather than erroring that, like so...

Install-Module 'PSModuleXYZ' -Repository 'PSRepo1', 'PSRepo2' -AllowDuplicates

..and not raise an exception.

The exact PSRepository (of the possible multiple ones) that the PSModule can be installed from could just be the first where it's available/found.

Expected Behavior (Option 2)

The alternative approach is to install from any available PSRepository as default (i.e. not use the additional switch in Opton 1) and also not throw the exception. This option may be less desired as it may be more likely to break existing processes and adds more risk to anyone currently using it (where this existing/current behaviour isn't desired).

Current Behavior

If a PSModule (e.g. PSModuleXYZ) exists on more than one PSRepository registered on a machine, when calling Install-Module like so...

Install-Module 'PSModuleXYZ'

...or...

Install-Module 'PSModuleXYZ' -RequiredVersion '1.2.3'

...will result in an error\exception (actually on the PackageManagement\Install-Package cmdlet) and prompt the user/caller to use the -Repository pararmeter, like so...

PackageManagement\Install-Package : Unable to install, multiple modules matched 'PSModuleXYZ'. Please specify a single -Repository.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1375 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : DisambiguateForInstall,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Possible Solution

There should be sufficient information in the "Expected Behaviour" sections to gauge an idea of possible implementation.

Context

In a large/exterprise organisation, it may be likely that there are multiple PSRepositories that exist on a machine, for example...

  • PSGallery (Public Gallery)
  • Company Internal (Production) PSRepositories
  • Company Internal (Development) PSRepositories
  • Personal/Private PSRepositories
  • Others?

...and these may be duplicated to support 'High Availability' and/or performance requirements depending upon the architecture (i.e. Internal PSRepositories in different Geographical locations).

Certain machines don't have access to the internet (i.e. those in more secure environments) and/or access the public PSGallery (e.g. blocked by company/security policy) and as such, other, internal repositories may have to have a copy of public PSModules so they can be installed to these machines.

As a result, of the above it's more likely that there are going to be more machines with multiple PSRepositories registered on them and thus a higher chance of having the same version of the same module (or even different versions of the same module) across the PSRepositories.

I would also suggest that a reasonable assumption (in the majority of cases) that the same version of the same PSModule in one PSRepository should be identical to the same version of the same PSModule in another repository, and as a result, it shouldn't matter which PSRepository the PSModule is installed from.

In addition, depending upon the environment (e.g. Dev,Test,Production etc.), different PSRepositories may be registered on different machines and as a result, being specific about which PSRepository to install from is undesired - Install from any available would be preferable.

Your Environment

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

Install-Module from nupkg file

It would be wonderful if PowerShell supported nupkg files natively (PowerShell/PowerShell#7259), but as a stop-gap (or perhaps, as part of the implementation of that), it would be really great if Install-Module had a parameter set where we just pass the path to a .nupkg file.

In fact, it would be great if you could associate powershell -c Install-Module "%1" -scope CurrentUser with the package extension, and people could then install modules on Windows by simply right-clicking and choosing Install as PowerShell Module...

NOTE: I think it would be important to also do PowerShell/PowerShellGet#794 while you were at it, to allow modules to more easily ship with multiple platform-specific implementations

Bonus points for making up your own file extension like .psmodule so we don't have the "Install as PowerShell Module" option on all our .nupkg files...

Update-Module "untrusted repository" prompting is broken

I assume that when modules are being UPDATED, they're only updated from the original source repository? If not, why?

Not to put it too strongly, but the way that prompting happens in Update-Module is

  1. Awful: You get prompted for every module from an untrusted repository. Not once per repository as happens when installing modules.
  2. Confusing: You're not told which module(s) are being updated, and you're only given a repository nickname (this is a major problem on install as well, but it's particularly problematic with Update-Module when you're being prompted multiple times for the same repository)
  3. Pointless: I have already installed these modules once, and I have already chosen to trust the repository.

Assuming that I'm upgrading all my module, I'm being asked if I want to trust a repository without being told which module is being installed -- as a result, when I'm asked about trusting a repository, I don't have enough information. If the module came from an untrusted repository originally, then it's logical to assume it will come from there again. If it didn't, then I definitely don't want to trust it for an update ...

Ideally, I don't think I should be prompted if I already trusted the source for a module.

Failing that, I think the prompt has to include the module name, so I can make a decision.

Failing that, I should only be prompted once per repository, because being asked the same question multiple times even when I say Yes to all, is non-intuitive, confusing, and a waste of time.

[Feature Request] Session scope for Register-PSRepository

Team,
Can you please add session scope support for Register-PSRepository?

We have an internal build system that outputs PowerShell modules. Every successful build is published to an internal PSRepository (Artifactory server).
Every time we want to publish a module we have to deal with the following cases:

  • Is the repository already registered?
  • Is another repository with different name and the same SourceLocation already registered?
  • If the repository is already registered and we want to deploy on different url (PublishLocation) we have to modify the existing registration
  • Clean the build machine after build procedure (Unregister-PSRepository)
  • If 2 parallel builds are running on the same build machine at the same time this can cause conflicts (dealing with the same shared resource)

The problems described above can be avoided with Register-PSRepository operating on session level. Let me know if you have any questions.

Thanks,
Nedko

PowerShellGet/Gallery should use Namespaces like Nuget

PowershellGallery should use an ID Prefix Reservation system similar to the one used by Nuget.

This would make it easier to see which packages are owned by vertified organizations or open-source projects. This would also make it easier to find all packages from a project-- and not have to worry about deceptive package names.

PSGetModuleInfo.xml invalidates the module .cat file

Team,

After publishing and installing a module from PS Gallery we get one additional file called PSGetModuleInfo.xml. After calling Test-FileCatalog I get "ValidationFailed" result. This way our customers cannot verify the module content.

Thanks,
f012rt

Better error handling when a repo is already registered

From @WernerMairl on November 18, 2016 8:27

Hi
Working with Register-PSRepository i have found some behavior that was really unexpected.
Probably we are not talking about bugs but about usability....

  1. Repository uniqueness
    All the functions around PSRepository (Get, Register, Unregister) are using the Name Property/Argument to identify a Repo.

Seeing this API-Surface i'm assuming that the property Name is the one that implements the "unique" Key for Repos => expected behavior at the first look....

after playing a few hours with the api, i find out that internally NOT the Name must be unique but the property "SourceLocation" enforces uinqueness.

  • That means i'm not be able to register the same package Source with different Names
  • Means in different Powershell-Codebases that should run on the same server i must synchronize Repository NAMES....

To solve problems like that must select/filter my Repos by SourceLocation BUT the Get-PSRepo function doesn't implement filter for SourceLocation.... usability Issue, a property that is used as primary key should have some easy access....(yes i can do that with pure Powershell, but we are talking about API-Usability)

  1. ErrorActionPreference is ignored!
    If i call "Register-PSRepository" with a unique/random Name but a SourceLocation that is used in another Repo then the Function writes Error output.

PackageManagement\Register-PackageSource : The repository could not be registered because there exists a registered repository with Name 'XXXXX' and SourceLocation 'http://xxxxxxx.y.z.a:8080/api/odata'. To register
another repository with Name 'XXXXX', please unregister the existing repository using the Unregister-PSRepository cmdlet

I found the following unexpected behavior here:

$ErrorctionPreference value is "Stop" in the calling script => assuming that a exception can be catched with try catch
Register-PSRepository writes the error record but it does not FOLLOWS the STOP behavior.. it IGNORES!

To enforce the "expected" behavior i must expplicitely use
Register-PSRepository ......-ErrorAction Stop

I'm not a expert in all the coding and behavior rules for PS but
in 99% of my PS-Code i'm able to catch exceptions by using $ErrorActionPrefence on the global level
so i think that can be behavior issue inside Register-PSRepository

regards
Werner

Copied from original issue: PowerShell/PowerShell#2717

Add Class key to Includes hashtable

The PSRepositoryInfo object has an Includes hashtable with keys for the types of commands and resources in a module.

Please add a Class key for classes defined in the root module or ScriptsToProcess script that can be exported into the user's session.

Name                           Value
----                           -----
Function                       {}
RoleCapability                 {}
Command                        {}
DscResource                    {}
Workflow                       {}
Cmdlet                         {}

Need update notification for installed modules and scripts

  • Show toast notification for newer version of module in the gallery, if an older version of that module is installed on the system.
  • Notification should be enabled on all supported Platforms and PowerShell versions.
  • Registration can be at individual item level or for all installed modules/scripts.

Include version info in User-Agent

Modify the User-Agent string presented when we download packages from the gallery to include information about the software versions being used for the download process by including it in the User-Agent header. The gallery already records user-agent information but this is not currently very useful.

The same header would be sent to any other repository (such as an internal nuget feed or nuget.org). We would not emit telemetry directly from the powershellget, and would not get any information about downloads from other feeds than powershellgallery.com.

Desired information:
Version of PowerShellGet, PackageManagement (and NugetProvider?) (eg PowerShellGet 2.1.0)
Version and Edition of PowerShell (eg PowerShell Core 6.1.1)
Identifier for operating system

We should not include any personally identifiable information.

This would allow us to make better-informed decisions about which versions of the components above are most commonly-used in the wild.

If there are concerns about this proposal please note them below.

[Feature Request]: Ability to configure PSRepository on a system-wide level

It would be great if there was a way to register a PSRepository on the system-wide level, so that if configured once, it would work for all the users on a particular system.

Expected Behavior

Register-PSRepository should have a -Scope parameter added, to control whether a particular PSRepository needs to be registered for just the current user of for the whole system (similar to the behavior of Execution Policy). It would also be great to have an extra scope option, that would register PSRepository just for the current session (like mentioned in PowerShell/PowerShellGet#65)

Apart from the Register-PSRepository, the remaining set of the *-PSRepository cmdlets should also have the -Scope parameter. Set-PSRepository and Unregister-PSRepository cmdlets should require admin privileges to work against system-wide PSRepository settings and 'Get-PSRepository' cmdlet should not require admin privileges at all.

Current Behavior

Currently Register-PSRepository only works for the user that is executing the cmdlet.

Context

Having an ability to register PSRepository on a system-wide level would allow us to pre-configure our internal Repositories in the Virtual Machine templates, thus making the provisioning process much simpler.

Additionally, that would simplify maintaining existing PSRepository configurations in a consistent fashion across all our systems.

Your Environment

PS C:\Users> $PSVersionTable

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


PS C:\Users>
PS C:\Users> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PS...


PS C:\Users>
PS C:\Users> Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.1.1.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


    Directory: C:\Program Files (x86)\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


PS C:\Users>
PS C:\Users> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet            1.6.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent


PS C:\Users> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.208
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
NuGetProvider            2.8.5.208
PowerShellGet            1.6.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
PowerShellGet            1.1.2.0
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Need easy access to PowerShell Gallery DNS URLs

When any of the URLs for accessing the PowerShell Gallery change, some users are unable to access it due to firewall restrictions. This came up in the Sept 2018 update. Copying from a Gallery blog comment:

packages will be downloaded from psg-prod-eastus.azureedge.net instead of devopsgallerystorage.blob.core.windows.net,
Is there any chance to get the DNS names somewhere documented? Some companies with url access restrictions would be happy about this

We need to exclude this url in our proxy and firewall configuration. Currently in our dev environment we have exclusions for docker, .net core, npm, nuget and powershell. And with a change occurring every week or so it gets somehow frustrating to debug it every time.

Possible Solution

We should pre-announce when the URLs for the Gallery are changing, or new ones are made available.
In addition, recommended solution would be to document the URLs somewhere, such as in a file in GH that contains the direct access URLs in an easily used format.

BUG: Missing credentials cause TERMINATING exception.

I have used Register-PSRepository to add our internal PowerShell gallery, which requires credentials, and now I can't search for modules without explicitly specifying which galleries to search, or providing my credentials every time.

Expected Behavior

I should just get a warning that I can't access one of my repositories, and the other repositories should still be searched:

> Find-Module PSScriptAnalyzer
WARNING: Cannot access 'https://poshcode.pkgs.visualstudio.com/_packaging/PSModules/nuget/v2'. Are you missing 'Credential' parameter in the cmdlet?

Version    Name                                Repository           Description
-------    ----                                ----------           -----------
1.15.0     PSScriptAnalyzer                    PSGallery            PSScriptAnalyzer provides script analysis and checks for potential code defects in the ...

Current Behavior

As soon as a gallery fails, no other galleries are searched, and an error is thrown with text that implies that all the galleries were searched:

> Find-Module PSScriptAnalyzer
WARNING: Cannot access 'https://poshcode.pkgs.visualstudio.com/_packaging/PSModules/nuget/v2'. Are you missing 'Credential' parameter in the cmdlet?
ERROR: PackageManagement\Find-Package : No match was found for the specified search criteria and module name 'PSScriptAnalyzer'. Try Get-PSRepository to see all available registered module repositories.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.1.3.1\PSModule.psm1:1415 char:3
+         PackageManagement\Find-Package @PSBoundParameters | Microsoft ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...ets.FindPackage:FindPackage) [Find-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackage

Steps to Reproduce

  1. Register a repository which requires credentials to access (such as a VSO gallery, feel free to use my URL above). I
  2. Try to Find-Module

Context

This breaks scripts which didn't anticipate Find-Module or Install-Module failing.

However -- I feel I should point out that there's something weird going on in the ordering of things, because I was able to work around this by running unregister-module PSGallery and then re-registering the PSGallery under a different name.

Your Environment

> $PSVersionTable

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

> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0.2      Configuration                       {Add-MetadataConverter, ConsoleColor, ConvertFrom-Metadata, ConvertTo-Metadata...}
Script     1.6        DefaultParameter                    {Disable-DefaultParameter, Enable-DefaultParameter, Export-DefaultParameter, Get-DefaultParameter... Script     1.0.4      Environment                         {Add-Path, Get-SpecialFolder, Select-UniquePath, Set-AliasToFirst...}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     1.1.1.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.0.0      Pansies                             {New-Text, Write-Host, Get-Gradient, Text}
Script     2.3.1      PowerLine                           {Add-PowerLineBlock, Get-Elapsed, Get-SegmentedPath, Get-ShortenedPath...}
Script     1.1.3.1    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     1.1.0      Profile                             {ConvertTo-StringArray, Get-Quote, Set-HostColor, Update-ToolPath...}
Script     2.0.4      PSGit                               {GitConvertColor, Get-GitBranch, Get-GitChange, Get-GitInfo...}
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSReadlineKeyHandler, Set-PSReadlineKeyHa...


> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.1.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.1.3.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}

> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86, PackageSaveMode, FilterOnTag, Contains, AllowPrere... msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, Co... PowerShellGet            1.1.3.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Ta... Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86, PackageSaveMode, FilterOnTag, Contains, AllowPrere... ChocolateyGet            1.0.0.1          AdditionalArguments
Gist                     0.6.0.0
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
nuget                    2.8.5.207
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, Co... PowerShellGet            1.1.3.1          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Ta... PowerShellGet            1.1.2.0
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Publish-Module can't overwrite - nuget can

Expected Behavior

Overwriting modules should be possible - without bumping version number.

Current Behavior

I'm developing PowerShell modules, and I have two nuget repositories, one for snapshots (modules under development) and another one for releases (production ready modules). I'm using Artifactory as an artifact management system, and I've set up both repositories as nuget feeds in there.

First time I publish a module with PowerShellGet, it works. If I run the Publish-Module command again right after, it fails because it won't allow me to overwrite (the user psmodulewriter has permission to overwrite):

PS C:\> Publish-Module -Path 'C:\Workspace\code\UtilsModule' -Repository 'PSSnapshots' -NuGetApiKey 'psmodulewriter:password' -Credential 'psmodulewriter' -Force
PS C:\> Publish-Module -Path 'C:\Workspace\code\UtilsModule' -Repository 'PSSnapshots' -NuGetApiKey 'psmodulewriter:password' -Credential 'psmodulewriter' -Force
Publish-Module : The module 'UtilsModule' with version '0.0.1' cannot be published as the current version '0.0.1' is already available in the repository 'https://xxxx.jfrog.io/xxxxartifactory/api/nuget/xxxxPowerShellRepo-Snapshots/'.
At line:1 char:1
+ Publish-Module -Path 'C:\Workspace\code\UtilsModule' -Repository 'P ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Publish-Module], InvalidOperationException
    + FullyQualifiedErrorId : ModuleVersionIsAlreadyAvailableInTheGallery,Publish-Module

Possible Solution

A possible solution would be to use the -Force parameter in line 1257 on the master branch in PowerShellGet/PSModule.psm1 like so:

if(-not $Force -and ($currentPSGetItemInfo.Version -eq $moduleInfo.Version))

Context

I'm using a CI/CD process and would like to test the modules I'm developing through the pipeline often, without bumping the version number every time.

This is possible using nuget. If I download the .nupkg from Artifactory and push it with nuget, it overwrites the file without any problem:

PS C:\> nuget push C:\temp\UtilsModule.0.0.1.nupkg -Source PSSnapshots
Pushing UtilsModule.0.0.1.nupkg to 'https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots'...
  PUT https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots/
  Created https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots/ 751ms
Your package was pushed.
PS C:\> nuget push C:\temp\UtilsModule.0.0.1.nupkg -Source PSSnapshots
Pushing UtilsModule.0.0.1.nupkg to 'https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots'...
  PUT https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots/
  Created https://xxxx.jfrog.io/xxxx/api/nuget/xxxxPowerShellRepo-Snapshots/ 675ms
Your package was pushed.

Your Environment

PS C:\> $PSVersionTable

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

PS C:\> Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.0        GroupSet                            {BuildResourceCommonParameters, BuildResourceString, GroupSet}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Script     1.1.6.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.5.0.0    PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     1.0        ProcessSet                          {BuildResourceCommonParameters, BuildResourceString, ProcessSet}
Manifest   1.1        PSDesiredStateConfiguration         {Invoke-DscResource, Publish-DscConfiguration, Set-DscLocalConfigurationManager, Start-DscConfiguration...}
Script     1.0        ServiceSet                          {BuildResourceCommonParameters, BuildResourceString, ServiceSet}
Script     1.0        WindowsFeatureSet                   {BuildResourceCommonParameters, BuildResourceString, WindowsFeatureSet}
Script     1.0        WindowsOptionalFeatureSet           {BuildResourceCommonParameters, BuildResourceString, WindowsOptionalFeatureSet}

PS C:\> Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.5.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, Filter, Tag, Includes, DscResource, RoleCapability, Command, AcceptLicense, PublishLocation, ScriptSourceLocation, ScriptPublishLocation
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Give some way to configure psrepos via GPO or other method

We use an internal NuGet feed to host a lot of our module/scripts for people in IT. but everytime they get on a new box, they need to register that repo, which is very cumbersome, it would be nice if the PSRepository was not stored in CLIXML because that makes it pretty cumbersome to try and deploy those settings. i guess a logon script to be used, but that seems like the wrong direction to go to accomplish this.

Expected Behavior

maybe allow to have a machine targeted repo, similar to how powershell profiles work, where we can deploy an internal default PSRepo to machines.

Current Behavior

currently the PSRepository is user based, so this makes it hard to setup an internal repo on multipule machines.

Possible Solution

see expected behavor

Steps to Reproduce (for bugs)

Context

as we publish more our scripts and build internal modules, that cannot be published publicaly, i need a way to configure our internal repo on all machines. so users can use install/find-module/script OOB.

Your Environment

> $PSVersionTable

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

Get-Module

Get-Module -ListAvailable PowerShellGet,PackageManagement

Get-PackageProvider

Get-PackageProvider -ListAvailable

Non-Prerelease Modules do not install over Prerelease versions without -force

The new prerelease support allows for prerelease naming of the package, but that doesn't reflect at all on PowerShell's versioning.

If I install module foo with a version of 2.0.0-beta1 (and powershell version 2.0.0), then later try to install foo 2.0.0, the second module install will silently fail.

Expected Behavior

Installing the released version of a module should supercede the prerelease version.

(this would likely also impact other pre-release versions - i.e. upgrading from beta1 to beta2)

Current Behavior

Attempting to install the released version over a pre-release fails silently.

Steps to Reproduce (for bugs)

register-PSModuleRepository -name PreReleaseTest -SourceLocation https://www.myget.org/F/usepowershell/api/v2 
install-module PSConfAsia -allowprerelease -maximumversion 2.0.0-alpha-Repository PreReleaseTest -scope CurrentUser

## Print the version from PSGetModuleInfo
## Note the 2.0.0-alpha
([xml](cat ~\Documents\WindowsPowerShell\Modules\PSConfAsia\2.0.0\PSGetModuleInfo.xml -raw)).SelectNodes("//*[@N='NormalizedVersion']").'#text'

install-module PSConfAsia --maximumversion 2.0.0 -repository PreReleaseTest -scope CurrentUser

## Print the version from PSGetModuleInfo
## Still alpha
([xml](cat ~\Documents\WindowsPowerShell\Modules\PSConfAsia\2.0.0\PSGetModuleInfo.xml -raw)).SelectNodes("//*[@N='NormalizedVersion']").'#text'

install-module PSConfAsia --maximumversion 2.0.0 -repository PreReleaseTest -scope CurrentUser -force

## Print the version from PSGetModuleInfo
## How we have the release version
([xml](cat ~\Documents\WindowsPowerShell\Modules\PSConfAsia\2.0.0\PSGetModuleInfo.xml -raw)).SelectNodes("//*[@N='NormalizedVersion']").'#text'
> $PSVersionTable

 LoECDA-PS > $PSVersionTable

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

> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\Users\stmuraws\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


    Directory: C:\Program Files\WindowsPowerShell\Modules


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

"Find-Command" & "Install-Module" cmdlets should identify OS compatibility

From @MaximoTrinidad on September 28, 2016 13:29

Steps to reproduce

In Linux, using either Find-Command or Install-Module, will list all available (Windows and Linux).

Expected behavior

Install the module that can be executed Linux, as well as Windows.

It maybe a good idea to have these cmdlets check for the OS type before providing the list.

Actual behavior

A Module won't install because it need dependencies, or was built for Windows OS. Below, example has been addressed;
janegilring/PSVersion#5

psversionissue

Environment data

Linux: Ubuntu 16.04.1 64bit

PS /home/maxt> $PSVersionTable                                                  

Name                           Value                                           
----                           -----                                           
PSVersion                      6.0.0-alpha                                     
PSEdition                      Core                                            
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                         
BuildVersion                   3.0.0.0                                         
GitCommitId                    v6.0.0-alpha.10                                 
CLRVersion                                                                     
WSManStackVersion              3.0                                             
PSRemotingProtocolVersion      2.3                                             
SerializationVersion           1.1.0.1  

Copied from original issue: PowerShell/PowerShell#2374

Find-DscResource does not support wildcards for resource names

Steps to reproduce

Find-DscResource updateservices*

Expected behavior

Name                                Version    ModuleName                          Repository
----                                -------    ----------                          ----------
xHotfix                             2.7.0.0    xWindowsUpdate                      PSGallery
UpdateServicesClientDSC             1.1.0.0    UpdateServicesClientDSC             PSGallery
UpdateServicesApprovalRule          1.0.75.0   UpdateServicesDsc                   PSGallery
UpdateServicesCleanup               1.0.75.0   UpdateServicesDsc                   PSGallery
UpdateServicesServer                1.0.75.0   UpdateServicesDsc                   PSGallery

Actual behavior

(nothing is returned)

Environment data

Name                           Value
----                           -----
PSVersion                      6.2.0-preview.1
PSEdition                      Core
GitCommitId                    6.2.0-preview.1
OS                             Microsoft Windows 10.0.18290
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Install-Module does not find module if custom VSTS repo registered

I have 3 PSRepositories. PSGallery, VSTS, Nuget on-prem.
I want to install Pester module

Expected Behavior

Install-module 'Pester' should find modules in every psrepostory and then install it.

Current Behavior

PS C:\Users\t> Install-Module Pester -Proxy 'http://proxy:8080' -ProxyCredential $Cred -Debug
DEBUG: 00:00:00.0000021 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0001529 Debug: True
DEBUG: 00:00:00.0002408 ProxyCredential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0002963 Proxy: http://proxy:8080/
DEBUG: 00:00:00.0003305 Name: Pester
DEBUG: 00:00:00.0017832 INVOKING PowerShell Fn Get-DynamicOptions with args Provider that has length 1
DEBUG: 00:00:00.0033804 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0257777 Done calling powershell ยซGet-DynamicOptionsยป ยซPSModuleยป
DEBUG: 00:00:00.0341868 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0342435 Debug: True
DEBUG: 00:00:00.0342776 ProxyCredential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0343102 Proxy: http://proxy:8080/
DEBUG: 00:00:00.0343417 Name: Pester
DEBUG: 00:00:00.0356674 INVOKING PowerShell Fn Get-DynamicOptions with args Source that has length 1
DEBUG: 00:00:00.0370115 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0416523 Done calling powershell ยซGet-DynamicOptionsยป ยซPSModuleยป
DEBUG: 00:00:00.0487684 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0488213 Debug: True
DEBUG: 00:00:00.0488517 ProxyCredential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0488517 Proxy: http://proxy:8080/
DEBUG: 00:00:00.0489182 Name: Pester
DEBUG: 00:00:00.0500623 INVOKING PowerShell Fn Get-DynamicOptions with args Package that has length 1
DEBUG: 00:00:00.0514817 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0626423 Done calling powershell ยซGet-DynamicOptionsยป ยซPSModuleยป
DEBUG: 00:00:00.0785724 Calling New() : MethodName = 'GetDynamicOptions'
DEBUG: 00:00:00.0786264 Debug: True
DEBUG: 00:00:00.0786595 ProxyCredential: System.Management.Automation.PSCredential
DEBUG: 00:00:00.0786917 Proxy: http://proxy:8080/
DEBUG: 00:00:00.0787225 Name: Pester
DEBUG: 00:00:00.0798822 INVOKING PowerShell Fn Get-DynamicOptions with args Install that has length 1
DEBUG: 00:00:00.0811992 In PowerShellGet Provider - 'Get-DynamicOptions'.
DEBUG: 00:00:00.0885465 Done calling powershell ยซGet-DynamicOptionsยป ยซPSModuleยป
DEBUG: 00:00:02.2381372 Calling SearchForPackages. Name='Pester'
VERBOSE: Using the provider 'PowerShellGet' for searching packages.
DEBUG: 00:00:02.2404415 PackageProvider::FindPackage with name Pester
DEBUG: 00:00:02.2409007 Calling SearchForPackages After Select 1
DEBUG: 00:00:02.8408548 Calling New() : MethodName = 'FindPackage'
DEBUG: 00:00:02.8423451 ProviderName: PowerShellGet
DEBUG: 00:00:02.8442593 Type: Module
DEBUG: 00:00:02.8639346 MessageResolver: Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:02.8656233 ProxyCredential: System.Management.Automation.PSCredential
DEBUG: 00:00:02.8670347 Debug: True
DEBUG: 00:00:02.8683619 Proxy: http://proxy:8080/
DEBUG: 00:00:02.8699845 Scope: AllUsers
DEBUG: 00:00:02.8714744 AllowPrereleaseVersions: False
DEBUG: 00:00:02.8728025 Name: Pester
DEBUG: 00:00:02.8749958 INVOKING PowerShell Fn Find-Package with args System.String[], , ,  that has length 4
DEBUG: 00:00:02.8770521 In PowerShellGet Provider - 'Find-Package'.
DEBUG: 00:00:02.8783457 OPTION: ProviderName => PowerShellGet
DEBUG: 00:00:02.8798970 OPTION: Type => Module
DEBUG: 00:00:02.8811825 OPTION: MessageResolver => Microsoft.PowerShell.PackageManagement.Cmdlets.GetMessageString
DEBUG: 00:00:02.8825294 OPTION: ProxyCredential => System.Management.Automation.PSCredential
DEBUG: 00:00:02.8838649 OPTION: Debug => True
DEBUG: 00:00:02.8852856 OPTION: Proxy => http://proxy:8080/
DEBUG: 00:00:02.8866356 OPTION: Scope => AllUsers
DEBUG: 00:00:02.8879036 OPTION: AllowPrereleaseVersions => False
DEBUG: 00:00:02.8891588 OPTION: Name => Pester
VERBOSE: The -Repository parameter was not specified.  PowerShellGet will use all of the registered repositories.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:02.9183109 PackageProvider::FindPackage with name Pester
DEBUG: 00:00:02.9268413 Calling 'NuGet'::'FindPackage' - name='Pester', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:02.9652186 Iterating 'Pester'.
DEBUG: 00:00:02.9675696 There are '2' registered sources in 'NuGet' provider.
DEBUG: 00:00:02.9694252 Calling 'NuGetRequest'::'GetPackageById', 'Pester'.
VERBOSE: Retry downloading 'https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2' for '2' more times
VERBOSE: Retry downloading 'https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2' for '1' more times
VERBOSE: Retry downloading 'https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2' for '0' more times
WARNING: Cannot access 'https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2'. Are you missing 'Credential' parameter in the cmdlet?
DEBUG: 00:00:05.3775995 System.ArgumentException: Query Url https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2 is invalid.
   at Microsoft.PackageManagement.NuGetProvider.HttpClientPackageRepository..ctor(String queryUrl, NuGetRequest request)
   at Microsoft.PackageManagement.NuGetProvider.PackageRepositoryFactory.CreateRepository(String packageSource, NuGetRequest request)
   at Microsoft.PackageManagement.NuGetProvider.PackageSource.get_Repository()
   at Microsoft.PackageManagement.NuGetProvider.NuGetRequest.GetPackageById(PackageSource source, String name, NuGetRequest request, String requiredVersion, String minimumVersion, String m
aximumVersion, Boolean minInclusive, Boolean maxInclusive)
VERBOSE: Total package yield:'0' for the specified package 'Pester'.
DEBUG: 00:00:05.3978067 Completed iterating for 'Pester'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'https://www.powershellgallery.com/api/v2/' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:05.4076986 PackageProvider::FindPackage with name Pester
DEBUG: 00:00:05.4267941 Calling 'NuGet'::'FindPackage' - name='Pester', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:05.4287838 Iterating 'Pester'.
VERBOSE: Total package yield:'0' for the specified package 'Pester'.
DEBUG: 00:00:05.4327269 Completed iterating for 'Pester'.
VERBOSE: Getting the provider object for the PackageManagement Provider 'NuGet'.
VERBOSE: The specified Location is 'http://on-prem:8080/nuget/' and PackageManagementProvider is 'NuGet'.
DEBUG: 00:00:05.4431985 PackageProvider::FindPackage with name Pester
DEBUG: 00:00:05.4493776 Calling 'NuGet'::'FindPackage' - name='Pester', requiredVersion='',minimumVersion='', maximumVersion='''.
DEBUG: 00:00:05.4796371 Iterating 'Pester'.
VERBOSE: Total package yield:'0' for the specified package 'Pester'.
DEBUG: 00:00:05.4844730 Completed iterating for 'Pester'.
DEBUG: 00:00:05.4867117 PowerShell Script 'PSModule' Function 'Find-Package' returns null.
DEBUG: 00:00:05.4887791 Done calling powershell ยซFind-Packageยป ยซPSModuleยป
DEBUG: 00:00:05.4906182 unmatched package name='Pester'
PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'Pester'. Try Get-PSRepository to see all available registered module repositories
.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.0\PSModule.psm1:2057 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Steps to Reproduce (for bugs)

  1. Import-Module PowerShellGet -RequiredVersion 1.6.0
  2. Register VSTS repo
  3. Add PackageProvider Source to Nuget PackageProvider for that VSTS repo
  4. Try install module Pester. Do not specify Credential for that VSTS repo to make skip it.

Context

On-prem VM under the proxy

Possible Solution

If you provide -Credential for VSTS repo it works well. Why?

Your Environment

$PSVersionTable

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

> Get-Module

ModuleType Version    Name                                ExportedCommands                                                                                                                 
---------- -------    ----                                ----------------                                                                                                                 
Manifest   1.0.0.0    ActiveDirectory                     {Add-ADComputerServiceAccount, Add-ADDomainControllerPasswordReplicationPolicy, Add-ADFineGrainedPasswordPolicySubject, Add-AD...
Script     1.0        GroupSet                            {BuildResourceCommonParameters, BuildResourceString, GroupSet}                                                                   
Script     1.0.0.0    ISE                                 {Get-IseSnippet, Import-IseSnippet, New-IseSnippet}                                                                              
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Content...}                                                               
Manifest   3.0.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}                                        
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}                                                                        
Manifest   3.0.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}                                                  
Script     1.1.7.0    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}                                                        
Script     1.6.0      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}                                                            
Script     1.0        ProcessSet                          {BuildResourceCommonParameters, BuildResourceString, ProcessSet}                                                                 
Manifest   1.1        PSDesiredStateConfiguration         {Invoke-DscResource, Publish-DscConfiguration, Set-DscLocalConfigurationManager, Start-DscConfiguration...}                      
Script     1.0        ServiceSet                          {BuildResourceCommonParameters, BuildResourceString, ServiceSet}                                                                 
Manifest   21.0.17199 SqlServer                           {Add-RoleMember, Add-SqlAvailabilityDatabase, Add-SqlAvailabilityGroupListenerStaticIp, Add-SqlAzureAuthenticationContext...}    
Script     1.0        WindowsFeatureSet                   {BuildResourceCommonParameters, BuildResourceString, WindowsFeatureSet}                                                          
Script     1.0        WindowsOptionalFeatureSet           {BuildResourceCommonParameters, BuildResourceString, WindowsOptionalFeatureSet}                                                  



> Get-Module -ListAvailable PowerShellGet,PackageManagement

    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                 
---------- -------    ----                                ----------------                                                                                                                 
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                                                           
Script     1.1.1.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                                                           
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                                                           
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                                                     
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                                                     
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}   

> Get-PackageProvider
Name                     Version          DynamicOptions                                                                                                                                   
----                     -------          --------------                                                                                                                                   
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86, PackageSaveMode, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, Sk...
msi                      3.0.0.0          AdditionalArguments                                                                                                                              
msu                      3.0.0.0                                                                                                                                                           
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate          
PowerShellGet            1.6.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, I...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent   

> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions                                                                                                                                   
----                     -------          --------------                                                                                                                                   
Chocolatey               2.8.5.130        SkipDependencies, ContinueOnFailure, ExcludeVersion, ForceX86, PackageSaveMode, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, Sk...
msi                      3.0.0.0          AdditionalArguments                                                                                                                              
msu                      3.0.0.0                                                                                                                                                           
nuget                    2.8.5.208                                                                                                                                                         
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate          
PowerShellGet            1.6.0.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, I...
PowerShellGet            1.1.2.0                                                                                                                                                           
PowerShellGet            1.0.0.1                                                                                                                                                           
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent


> Get-PackageSource
Name                             ProviderName     IsTrusted  Location                                                                                                                      
----                             ------------     ---------  --------                                                                                                                      
chocolatey                       Chocolatey       False      http://chocolatey.org/api/v2/                                                                                                 
nuget.org                        NuGet            False      https://www.nuget.org/api/v2/                                                                                                 
VSTS                             NuGet            True       https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2                                         
VSTS                             PowerShellGet    True       https://x.pkgs.visualstudio.com/_packaging/TFSOnlinePackages/nuget/v2                                         
PSGallery                        PowerShellGet    True       https://www.powershellgallery.com/api/v2/                                                                                     
OnPrem                           PowerShellGet    False      http://on-prem:8080/nuget/ 

Missing NuGetApiKey should not throw exceptions on Publish-Module

The NuGetApiKey is not marked mandatory on Publish-Module.

In point of fact, there are NuGet repositories, like the Visual Studio Online package repositories, which require credentials rather than API keys, so this error (with id "NuGetApiKeyIsRequiredForNuGetBasedGalleryService") is technically incorrect anyway.

You should just try the publish and provide proper errors when and if the authentication fails.

Can't Uninstall/Remove AzureRM module from PowerShell on Mac OS

Expected Behavior

I expect to be able to uninstall the AzureRM complete module with command

>Uninstall-Module AzureRM -AllVersions -Force 

on the Mac OS

Current Behavior

When trying to uninstall the AzureRM module with the following command:

>Uninstall-Module AzureRM -AllVersions -Force 

and listed Azure related modules hoping that they are gone, but apparently they haven't been removed:

Get-Module -ListAvailable |Where-Object {$_.Name -like 'AzureRM*'}                                                                                                                         


    Directory: /Users/basia/.local/share/powershell/Modules


ModuleType Version    Name                                ExportedCommands                                                                                                                                 
---------- -------    ----                                ----------------                                                                                                                                 
Script     0.4.7      AzureRM.AnalysisServices            {Resume-AzureRmAnalysisServicesServer, Suspend-AzureRmAnalysisServicesServer, Get-AzureRmAnalysisServicesServer, Remove-AzureRmAnalysisService...
Script     4.4.1      AzureRM.ApiManagement               {Add-AzureRmApiManagementRegion, Get-AzureRmApiManagementSsoToken, New-AzureRmApiManagementHostnameConfiguration, New-AzureRmApiManagementRegi...
Script     3.4.1      AzureRM.Automation                  {Get-AzureRMAutomationHybridWorkerGroup, Get-AzureRmAutomationJobOutputRecord, Import-AzureRmAutomationDscNodeConfiguration, Export-AzureRmAut...
Script     3.4.1      AzureRM.Backup                      {Backup-AzureRmBackupItem, Enable-AzureRmBackupContainerReregistration, Get-AzureRmBackupContainer, Register-AzureRmBackupContainer...}          
Script     3.4.1      AzureRM.Batch                       {Remove-AzureRmBatchAccount, Get-AzureRmBatchAccount, Get-AzureRmBatchAccountKeys, New-AzureRmBatchAccount...}                                   
Script     0.13.7     AzureRM.Billing                     {Get-AzureRmBillingInvoice, Get-AzureRmBillingPeriod}                                                                                            
Script     3.4.1      AzureRM.Cdn                         {Get-AzureRmCdnProfile, Get-AzureRmCdnProfileSsoUrl, New-AzureRmCdnProfile, Remove-AzureRmCdnProfile...}                                         
Script     0.8.7      AzureRM.CognitiveServices           {Get-AzureRmCognitiveServicesAccount, Get-AzureRmCognitiveServicesAccountKey, Get-AzureRmCognitiveServicesAccountSkus, New-AzureRmCognitiveSer...
Script     3.4.1      AzureRM.Compute                     {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}                        
Manifest   0.9.1      AzureRM.Compute.Netcore             {Remove-AzureRmAvailabilitySet, Get-AzureRmAvailabilitySet, New-AzureRmAvailabilitySet, Update-AzureRmAvailabilitySet...}                        
Script     0.2.7      AzureRM.Consumption                 Get-AzureRmConsumptionUsageDetail                                                                                                                
Script     0.0.2      AzureRM.ContainerInstance           {New-AzureRmContainerGroup, Get-AzureRmContainerGroup, Remove-AzureRmContainerGroup, Get-AzureRmContainerInstanceLog}                            
Script     0.2.7      AzureRM.ContainerRegistry           {New-AzureRmContainerRegistry, Get-AzureRmContainerRegistry, Update-AzureRmContainerRegistry, Remove-AzureRmContainerRegistry...}                
Script     3.4.1      AzureRM.DataFactories               {Remove-AzureRmDataFactory, Get-AzureRmDataFactoryRun, Get-AzureRmDataFactorySlice, Save-AzureRmDataFactoryLog...}                               
Script     0.2.1      AzureRM.DataFactoryV2               {Set-AzureRmDataFactoryV2, Get-AzureRmDataFactoryV2, Remove-AzureRmDataFactoryV2, Set-AzureRmDataFactoryV2LinkedService...}                      
Script     3.4.1      AzureRM.DataLakeAnalytics           {Get-AzureRmDataLakeAnalyticsDataSource, New-AzureRmDataLakeAnalyticsCatalogCredential, Remove-AzureRmDataLakeAnalyticsCatalogCredential, Remo...
Script     4.4.1      AzureRM.DataLakeStore               {Get-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreTrustedIdProvider, Remove-AzureRmDataLakeStoreFirewallRule, Set-AzureRm...
Script     3.4.1      AzureRM.DevTestLabs                 {Get-AzureRmDtlAllowedVMSizesPolicy, Get-AzureRmDtlAutoShutdownPolicy, Get-AzureRmDtlAutoStartPolicy, Get-AzureRmDtlVMsPerLabPolicy...}          
Script     3.4.1      AzureRM.Dns                         {Get-AzureRmDnsRecordSet, New-AzureRmDnsRecordConfig, Remove-AzureRmDnsRecordSet, Set-AzureRmDnsRecordSet...}                                    
Script     0.1.1      AzureRM.EventGrid                   {New-AzureRmEventGridTopic, Get-AzureRmEventGridTopic, Set-AzureRmEventGridTopic, New-AzureRmEventGridTopicKey...}                               
Script     0.4.7      AzureRM.EventHub                    {New-AzureRmEventHubKey, Get-AzureRmEventHubNamespace, Get-AzureRmEventHubNamespaceAuthorizationRule, Get-AzureRmEventHubNamespaceKey...}        
Script     3.4.1      AzureRM.HDInsight                   {Get-AzureRmHDInsightJob, New-AzureRmHDInsightSqoopJobDefinition, Wait-AzureRmHDInsightJob, New-AzureRmHDInsightStreamingMapReduceJobDefinitio...
Script     3.4.1      AzureRM.Insights                    {Get-AzureRmUsage, Get-AzureRmMetricDefinition, Get-AzureRmMetric, Remove-AzureRmLogProfile...}                                                  
Script     2.4.1      AzureRM.IotHub                      {Add-AzureRmIotHubKey, Get-AzureRmIotHubEventHubConsumerGroup, Get-AzureRmIotHubConnectionString, Get-AzureRmIotHubJob...}                       
Script     3.4.1      AzureRM.KeyVault                    {Add-AzureKeyVaultCertificate, Set-AzureKeyVaultCertificateAttribute, Stop-AzureKeyVaultCertificateOperation, Get-AzureKeyVaultCertificateOper...
Script     3.4.1      AzureRM.LogicApp                    {Get-AzureRmIntegrationAccountAgreement, Get-AzureRmIntegrationAccountCallbackUrl, Get-AzureRmIntegrationAccountCertificate, Get-AzureRmIntegr...
Script     0.15.7     AzureRM.MachineLearning             {Move-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentAssociation, Get-AzureRmMlCommitmentPlanUsageHistory, Remove-AzureRmMlCommitmentP...
Script     0.1.0      AzureRM.MachineLearningCompute      {Get-AzureRmMlOpCluster, Get-AzureRmMlOpClusterKey, Test-AzureRmMlOpClusterSystemServicesUpdateAvailability, Update-AzureRmMlOpClusterSystemSe...
Script     0.1.0      AzureRM.MarketplaceOrdering         {Get-AzureRmMarketplaceTerms, Set-AzureRmMarketplaceTerms}                                                                                       
Script     0.7.7      AzureRM.Media                       {Sync-AzureRmMediaServiceStorageKeys, Set-AzureRmMediaServiceKey, Get-AzureRmMediaServiceKeys, Get-AzureRmMediaServiceNameAvailability...}       
Script     4.4.1      AzureRM.Network                     {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGateway...
Manifest   0.9.1      AzureRM.Network.Netcore             {Add-AzureRmApplicationGatewayAuthenticationCertificate, Get-AzureRmApplicationGatewayAuthenticationCertificate, New-AzureRmApplicationGateway...
Script     3.4.1      AzureRM.NotificationHubs            {Get-AzureRmNotificationHub, Get-AzureRmNotificationHubAuthorizationRules, Get-AzureRmNotificationHubListKeys, Get-AzureRmNotificationHubPNSCr...
Script     3.4.1      AzureRM.OperationalInsights         {New-AzureRmOperationalInsightsAzureActivityLogDataSource, New-AzureRmOperationalInsightsCustomLogDataSource, Disable-AzureRmOperationalInsigh...
Script     3.4.1      AzureRM.PowerBIEmbedded             {Remove-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollection, Get-AzureRmPowerBIWorkspaceCollectionAccessKeys, Get-AzureRm...
Script     3.4.1      AzureRM.profile                     {Disable-AzureRmDataCollection, Disable-AzureRmContextAutosave, Enable-AzureRmDataCollection, Enable-AzureRmContextAutosave...}                  
Manifest   0.9.1      AzureRM.Profile.Netcore             {Disable-AzureRmDataCollection, Enable-AzureRmDataCollection, Remove-AzureRmEnvironment, Get-AzureRmEnvironment...}                              
Script     3.4.1      AzureRM.RecoveryServices            {Get-AzureRmRecoveryServicesBackupProperty, Get-AzureRmRecoveryServicesVault, Get-AzureRmRecoveryServicesVaultSettingsFile, New-AzureRmRecover...
Script     3.4.1      AzureRM.RecoveryServices.Backup     {Backup-AzureRmRecoveryServicesBackupItem, Get-AzureRmRecoveryServicesBackupManagementServer, Get-AzureRmRecoveryServicesBackupContainer, Unre...
Script     3.4.1      AzureRM.RedisCache                  {Remove-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCacheScheduleEntry, Get-AzureRmRedisCachePatchSchedule, New-AzureRmRedisCachePatchSche...
Script     0.2.7      AzureRM.Relay                       {New-AzureRmRelayNamespace, Get-AzureRmRelayNamespace, Set-AzureRmRelayNamespace, Remove-AzureRmRelayNamespace...}                               
Script     4.4.1      AzureRM.Resources                   {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}                            
Manifest   0.9.1      AzureRM.Resources.Netcore           {Get-AzureRmProviderOperation, Remove-AzureRmRoleAssignment, Get-AzureRmRoleAssignment, New-AzureRmRoleAssignment...}                            
Script     0.15.7     AzureRM.Scheduler                   {Disable-AzureRmSchedulerJobCollection, Enable-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJobCollection, Get-AzureRmSchedulerJob...}     
Script     3.4.1      AzureRM.ServerManagement            {Invoke-AzureRmServerManagementPowerShellCommand, Get-AzureRmServerManagementSession, New-AzureRmServerManagementSession, Remove-AzureRmServer...
Script     0.4.7      AzureRM.ServiceBus                  {New-AzureRmServiceBusNamespace, Get-AzureRmServiceBusNamespace, Set-AzureRmServiceBusNamespace, Remove-AzureRmServiceBusNamespace...}           
Script     0.2.7      AzureRM.ServiceFabric               {Add-AzureRmServiceFabricApplicationCertificate, Add-AzureRmServiceFabricClientCertificate, Add-AzureRmServiceFabricClusterCertificate, Add-Az...
Script     4.4.1      AzureRM.SiteRecovery                {Get-AzureRmSiteRecoveryFabric, New-AzureRmSiteRecoveryFabric, Remove-AzureRmSiteRecoveryFabric, Stop-AzureRmSiteRecoveryJob...}                 
Script     3.4.1      AzureRM.Sql                         {Get-AzureRmSqlDatabaseTransparentDataEncryption, Get-AzureRmSqlDatabaseTransparentDataEncryptionActivity, Set-AzureRmSqlDatabaseTransparentDa...
Script     3.4.1      AzureRM.Storage                     {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}                            
Manifest   0.9.1      AzureRM.Storage.Netcore             {Get-AzureRmStorageAccount, Get-AzureRmStorageAccountKey, New-AzureRmStorageAccount, New-AzureRmStorageAccountKey...}                            
Script     3.4.1      AzureRM.StreamAnalytics             {Get-AzureRmStreamAnalyticsFunction, Get-AzureRmStreamAnalyticsDefaultFunctionDefinition, New-AzureRmStreamAnalyticsFunction, Remove-AzureRmSt...
Script     3.4.1      AzureRM.Tags                        {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}                                                                                              
Manifest   0.9.1      AzureRM.Tags.Netcore                {Remove-AzureRmTag, Get-AzureRmTag, New-AzureRmTag}                                                                                              
Script     3.4.1      AzureRM.TrafficManager              {Disable-AzureRmTrafficManagerEndpoint, Enable-AzureRmTrafficManagerEndpoint, Set-AzureRmTrafficManagerEndpoint, Get-AzureRmTrafficManagerEndp...
Script     3.4.1      AzureRM.UsageAggregates             Get-UsageAggregates                                                                                                                              
Script     3.4.1      AzureRM.Websites                    {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan...}                               
Manifest   0.9.1      AzureRM.Websites.Netcore            {Get-AzureRmAppServicePlan, Set-AzureRmAppServicePlan, New-AzureRmAppServicePlan, Remove-AzureRmAppServicePlan...}   

Possible Solution

there is a workarround suggested:

Get-Module -ListAvailable | Where-Object {$_.Name -like 'AzureRM*'} | Uninstall-Module

Steps to Reproduce (for bugs)

First I run the command:

Install-Module` AzureRM -AllowClobber -Scope CurrentUser   

not being aware that I won't be able to use it on my Mac OS Sierr 10.12.6.
When I found issue #4090 I have run the command:

Install-Module` AzureRM.netcore -AllowClobber -Scope CurrentUser 

After that, I still couldn't run

Login-AzureRmAccount 

because still got an error:
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.

I have tried uninstalling the AzureRM and AzureRM.netcore module with the following command:

Uninstall-Module AzureRM -AllVersions -Force 
Uninstall-Module AzureRM.netcore -AllVersions -Force 

Then I have tried to install AzureRM.netcore again

Install-Module` AzureRM.netcore -AllowClobber -Scope CurrentUser 

and run the command

Login-AzureRmAccount 

But got exactly the same error.
Login-AzureRmAccount : The 'Login-AzureRmAccount' command was found in the module 'AzureRM.profile', but the module could not be loaded. For more information, run 'Import-Module AzureRM.profile'.
When I run

Import-Module AzureRM.profile   

Got an error:
Import-Module : Could not load file or assembly 'System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

I have tried uninstalling the AzureRM and AzureRM.netcore module again with the following command:

Uninstall-Module AzureRM -AllVersions -Force 
Uninstall-Module AzureRM.netcore -AllVersions -Force 

and listed Azure related modules hoping that they are gone, but apparently they haven't been removed

Context

Your Environment

```powershell
> $PSVersionTable
Name                           Value                                                                                                                                                                       
----                           -----                                                                                                                                                                       
PSVersion                      6.0.0-beta.9                                                                                                                                                                
PSEdition                      Core                                                                                                                                                                        
GitCommitId                    v6.0.0-beta.9                                                                                                                                                               
OS                             Darwin 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64                                                              
Platform                       Unix                                                                                                                                                                        
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                                     
PSRemotingProtocolVersion      2.3                                                                                                                                                                         
SerializationVersion           1.1.0.1                                                                                                                                                                     
WSManStackVersion              3.0     

Register-PSRepository should support persistent credentials

In general package managers allow you to specify credentials when registering a package source which are then used by downstream functions that use that source. PowershellGet appears to allow you to do this via the -Credential parameter, but the credential is not used later by Find-Module. I believe that Find-Module, Install-Module, Save-Module, and Publish-Module should all be able to use the credential supplied with the source.

## Current Behavior

Register-PSRepository -Name Artifactory `
    -SourceLocation  $url `
    -PublishLocation $url `
    -InstallationPolicy Trusted `
    -Credential $Credential


Find-Module -Repository Artifactory 

<#
WARNING: Cannot access 'http://someurl'. Are you missing 'Credential' parameter in the cmdlet?
WARNING: Unable to resolve package source 'http://someurl'.

Downstream functions that use the source should use the credential that was used to register the source.
#>


## Context

The problem I'm trying to solve is to be able to setup an internal authenticated feed for powershell modules. Further, I'd like to be able to install them programatically from scripts (as in when setting up a new build agent). Requiring any human interaction whatever during this process breaks my automated build system.

## Your Environment
<!--- Include at least the output from $PSVersionTable -->

```PowerShell

> $PSVersionTable
Name                           Value                                                      
----                           -----                                                      
PSVersion                      5.0.10240.17146                                            
WSManStackVersion              3.0                                                        
SerializationVersion           1.1.0.1                                                    
CLRVersion                     4.0.30319.42000                                            
BuildVersion                   10.0.10011.16384                                           
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                    
PSRemotingProtocolVersion      2.3    
> Get-Module

> Get-Module -ListAvailable PowerShellGet,PackageManagement
C:\Windows\system32> Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands                
---------- -------    ----                                ----------------                
Script     1.1.3.0    PackageManagement                   {Find-Package, Get-Package, G...
Binary     1.0.0.0    PackageManagement                   {Find-Package, Get-Package, G...
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module,...
Script     1.0        PowerShellGet                       {Install-Module, Find-Module,...
Script     1.1.3.0    PackageManagement                   {Find-Package, Get-Package, G...
Binary     1.0.0.0    PackageManagement                   {Find-Package, Get-Package, G...
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module,...
Script     1.0        PowerShellGet                       {Install-Module, Find-Module,...


> Get-PackageProvider
C:\Windows\system32> Get-PackageProvider

Name                     Version          DynamicOptions                                  
----                     -------          --------------                                  
msi                      3.0.0.0          AdditionalArguments                             
msu                      3.0.0.0                                                          
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDepen...
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, Allow...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent 

> Get-PackageProvider -ListAvailable
C:\Windows\system32> Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions                                  
----                     -------          --------------                                  
msi                      3.0.0.0          AdditionalArguments                             
msu                      3.0.0.0                                                          
NuGet                    2.8.5.208        Destination, ExcludeVersion, Scope, SkipDepen...
NuGet                    2.8.5.127        Destination, SkipDependencies, ContinueOnFail...
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, Allow...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent 
PSModule                 1.0.0.0          PackageManagementProvider, Location, InstallU...

Uninstall-Module: add ability to uninstall dependent modules

From @dmilov on March 21, 2017 8:1

The use-case is to upgrade multiple modules to their new version. When there is a module with number of dependent modules Install-Module allows installing all dependent modules at once. If I need to upgrade the modules to new version with no willing to have multiple versions of certain module I'd expect to be able to uninstall module with all dependent modules at ones using Uninstall-Module.

Here is an example

Module A with version 1.0
Module B with version 1.0, which is required module in the A module's manifest

This call:
Install-Module -Name A -RequiredVersion 1.0

installs both A and B

When new versions of the above modules are published

Module A with version 2.0
Module B with version 2.0

I'd like to be able to

Uninstall-Module -Name A
Install-Module -Name A -RequiredVersion 2.0

and as a result to have installed only

A version 2.0
B version 2.0

Copied from original issue: PowerShell/PowerShell#3379

AllowClobber should write a warning about command collisions

Can we please have Install-Module with -AllowClobber write a warning about command collisions, so that we still get notified about them as we install?

Personally, I think that should be the default behavior. I mean, hypothetically a user can always cancel or uninstall if it gets in the way, but so far I have never not installed a module because of the command-collision error, so I'm just annoyed at having to run Install-Module commands two or three times.

Make all functions use the default proxy(if the proxy was enabled) when no proxy specified

Expected Behavior

register the ps repository successfully

Current Behavior

nothing happened

Possible Solution

when no proxy specified, then invoke the default proxy (when the proxy was enabled)
https://stackoverflow.com/questions/571429/powershell-web-requests-and-proxies

Steps to Reproduce (for bugs)

set the proxy on computer

Context

related to PowerShell/WindowsCompatibility#45
I want to register ps repository

Your Environment

> $PSVersionTable
Name                           Value
----                           -----
PSVersion                      6.1.0
PSEdition                      Core
GitCommitId                    6.1.0
OS                             Microsoft Windows 10.0.16299
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0
> Get-Module
ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        build                               {Clear-PSRepo, Compress-TestContent, Convert-TxtResourceToXml, ConvertFrom-PesterLog...}
Script     0.0        chuck                               Reset-FolderTime
Script     0.0        Get-PSGalleryApiAvailability
Manifest   6.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}
Manifest   6.1.0.0    Microsoft.PowerShell.Management     {Add-Content, Clear-Content, Clear-Item, Clear-ItemProperty...}
Manifest   6.1.0.0    Microsoft.PowerShell.Security       {ConvertFrom-SecureString, ConvertTo-SecureString, Get-Acl, Get-AuthenticodeSignature...}
Manifest   6.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Manifest   6.1.0.0    Microsoft.WSMan.Management          {Connect-WSMan, Disable-WSManCredSSP, Disconnect-WSMan, Enable-WSManCredSSP...}
Script     1.1.7.2    PackageManagement                   {Find-Package, Find-PackageProvider, Get-Package, Get-PackageProvider...}
Script     1.0.0.0    posh-git                            {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranchName, Get-GitBranchStatusColor...}
Script     2.0.1      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}
Script     2.0.0      PSReadLine                          {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PSReadLineKeyHandler, Set-PSReadLineKeyHandler...}
> Get-Module -ListAvailable PowerShellGet,PackageManagement
ModuleType Version    Name                                PSEdition ExportedCommands
---------- -------    ----                                --------- ----------------
Script     1.1.7.2    PackageManagement                   Desk      {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}
Script     1.6.7      PowerShellGet                       Desk      {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}
> Get-PackageProvider
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.6.7.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, Ac...
> Get-PackageProvider -ListAvailable
Name                     Version          DynamicOptions
----                     -------          --------------
NuGet                    2.8.5.210        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag, Contains, AllowPrereleaseVersions, ConfigFile, SkipValidate
PowerShellGet            1.6.7.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, InstallUpdate, NoPathUpdate, AllowPrereleaseVersions, Filter, Tag, Includes, DscResource, RoleCapability, Command, Ac...

PSGet needs to support selectively installing modules that support multiple platform runtimes

As more module authors are trying to support cross-platform and cross-PowerShell (Windows PowerShell versions and PSCore6), PSGet should adopt same packaging as nupkg for multiple runtimes. Conceptually, the module author would layout their module like:

  • MyModule
    • Runtimes
      • osx-x64
      • win-x64
      • win-x86
      • linux-x64
      • linux-arm32

When user does install-module, it should only install the bits for the runtime that matches the system. save-module should probably save all the runtimes. Similar structure for differentiating PowerShell versions.

Make Update-module behave more like nuget update/choco update

Expected Behavior

Example from related tool

in chocolatey and I believe nuget as well you can install a package that isn't already installed or update one that is with choco update packagename or nuget update packagename this makes it so one command can be universal for installing or upgrading a package making dependency handling and general install/maintenance an easier one line task.

Application

If Update-Module would call install-module if it finds the module in a trusted repository when it isn't already installed, it could make for a much smoother experience.

Additional automation for reloading

Update-Module should also have the ability to 'reload' the module that was updated.
So as soon as the update or new install is done it removes the module from the session if it already exists and then imports the new version unless it was otherwise specified to not import

Current Behavior

Installations

If you try to run update-module on a module that isn't installed it just says that one isn't installed

Reloading

Currently to get the new version of a module in your powershell session properly you need to

  1. update the module
  2. remove the module
    3 import the module
    If you try to just import the module after updating, it will import both version side by side.
    While I realize there are times when side by side module versions may be needed, other times this creates collisions and confusion as to which version of any given function will end up being used.

Possible Solution

For adding installing, I imagine a try/catch block for catching when modules aren't already installed and trying to install would do the trick for most cases.

perhaps reloading could be implemented via switch parameter to turn this off if it became default behavior or on to do this on demand
i.e there be a -Import or -reload or alternatively and preferably a -noreload or -noimport switch.
There could also just be a separate function for this functionality such as sync-module or some other verb that isn't there yet.

Context

It becomes a bit tedious to have to run 3 different commands to get an updated module into a session or script. As well keeping modules up to date and getting new ones installed gets difficult. With chocolatey packages I only ever use the cup command because it is so much simpler to install and update with one command.

Your Environment

$PSVersionTable

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

Installing fails catastrophically when PreRelease modules have a binary assembly in use

PreRelease modules that have binary assemblies cannot be upgraded if they are imported in any PowerShell session on the machine, because the binary will be locked.

It's practically impossible to update a PreRelease version of a module with binaries if you import it in your profile.

Expected Behavior

Update-Module should work, and should never break a working module.

Current Behavior:

PackageManagement\Install-Package : Administrator rights are required to install or update. Log on to the computer with an account that has Administrator
rights, and then try again, or install by adding "-Scope CurrentUser" to your command. You can also try running the Windows PowerShell session with elevated
rights (Run as Administrator).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.6.7\PSModule.psm1:12955 char:20
+ ...           $sid = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (System.Collections.ArrayList:String) [Install-Package], Exception
    + FullyQualifiedErrorId : AdministratorRightsNeededOrSpecifyCurrentUserScope,Copy-Module,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

Unfortunately, this error message is utterly incorrect, in every way

First: administrator rights won't help. What we need to do is to close every instance of PowerShell (including in terminals, in editors, etc), and then open a new instance with -noprofile (NOTE: if we're trying to upgrade PSReadLine -- try using ISE, because that's the only way to avoid using PSReadLine).

Second: "adding -Scope CurrentUser to your command" won't help. That's not a valid parameter for this command! ๐Ÿ™ˆ๐Ÿ’ฅ๐Ÿ’€๐Ÿ”ฅ And in any case, we're actually trying to upgrade to CurrentUser scope! The reason we can't is because the file is locked, not because we are trying to install somewhere we're not allowed to.

Third: Why are we repeating the advice to run "the Windows PowerShell session with elevated
rights (Run as Administrator)." For goodness sakes!

Additionally, the failed upgrade results in obliterating the existing install of the module.

Because the previous install was in the same folder, it's now gone (except for that binary file) -- AND WE CANNOT REINSTALL IT for the same reason the upgrade failed.

Possible Solution

Two possible solutions. My favorite would be:

  1. Always install modules into folders with full semver names
  2. If there's a +metadata or -postfix create a junction point with the System.Version name. I.e. 4.0.0 -> 4.0.0-beta02 ...
  3. When updating a pre-release, just adjust the junction after the install is successful.

Alternatively, if junctions are not supported in the file system:

  1. When PowerShellGet realizes that it's going to be installing to the same folder as an existing module, it should move all of the files to a SemVer-named folder before attempting to install the new version.
  2. If the install fails for any reason (e.g. network interruption), it should clean up by moving the old version back!
  3. The old pre-release version could even be left behind (and restored if the user removes the new pre-release), and could be cleaned up explicitly by the user at a later date -- just like regular versions.

Steps To Reproduce:

  1. Install-Module PANSIES -RequiredVersion 1.4.0-beta02 -Scope CurrentUser
  2. Import-Module PANSIES
  3. Get-InstalledModule Pansies and see you have beta02
  4. Attempt to Update-Module PANSIES -AllowPrerelease (should update to -beta03 but will instead die in a mysterious fire)
  5. Get-InstalledModule Pansies and see you don't have beta03, nor do you have beta02 anymore!

Context

My module PANSIES, and the built-in PSReadLine are just two examples of this which I have imported in my profile (or which PowerShell imports by default) which simply break when you try to update them.

Your Environment

> $PSVersionTable

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

> Get-Module PowerShellGet

ModuleType Version    Name                                ExportedCommands                                                                                    
---------- -------    ----                                ----------------                                                                                    
Script     1.6.7      PowerShellGet                       {Find-Command, Find-DscResource, Find-Module, Find-RoleCapability...}                               


> Get-Module -ListAvailable PowerShellGet,PackageManagement

ModuleType Version    Name                                ExportedCommands                                                                                    
---------- -------    ----                                ----------------                                                                                    
Script     1.1.7.2    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                              
Script     1.1.7.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                              
Script     1.1.1.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                              
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-PackageSource...}                              
Script     1.6.7      PowerShellGet                       {Find-Command, Find-DSCResource, Find-Module, Find-RoleCapability...}                               
Script     1.6.0      PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                        
Script     1.1.3.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                        
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}                                        

Update-Module does not really update the module

Update-Module only installs a newer version. It does not remove the previous version. This is no different that using Install-Module except that it checks the current installed version an searches for a newer version. That search functionality would be better implemented as a -Update parameter for Install-Module.

Expected Behavior

Update-Module should replace the current version with a new version. Not install the new version side-by-side with the old version.

Possible Solutions

  1. Deprecate Update-Module and move the search for update functionality into Install-Module.
  2. Change Update-Module to remove the old version. This needs to be smart enough to remove all old versions of nested modules without breaking dependencies in other installed modules.

Context

Using the verb Update is confusing to customers. They expect the cmdlet to update what they have not install side-by-side. Also, the cmdlet reference does not explain this behavior.

We see this a lot with Azure PowerShell. They release a new version every month. After a few months you can have several versions installed taking up a lot of space.

Your Environment

PS C:\Git>  $PSVersionTable

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


PS C:\Git>  Get-Module

ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     0.0        chocolateyProfile                   {TabExpansion, Update-SessionEnvironment, refreshenv}
Manifest   3.1.0.0    Microsoft.PowerShell.Management     {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Cont...
Manifest   3.1.0.0    Microsoft.PowerShell.Utility        {Add-Member, Add-Type, Clear-Variable, Compare-Object...}
Script     0.7.0      posh-git                            {Add-PoshGitToProfile, Add-SshKey, Enable-GitColors, Get-Al...
Script     1.2        PSReadline                          {Get-PSReadlineKeyHandler, Get-PSReadlineOption, Remove-PSR...
Script     1.0.0.1    PSYaml                              {Convert-YAMLtoJSON, ConvertFrom-YAML, ConvertFrom-YAMLDocu...
Script     1.0        sdwheeler.utilities                 {close-SQLite, ConvertFrom-Base64, convertfrom-htmlencoding...


PS C:\Git>  Get-Module -ListAvailable PowerShellGet,PackageManagement


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.1.3.0    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packag...
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packag...
Script     1.1.2.0    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}
Script     1.0.0.1    PowerShellGet                       {Install-Module, Find-Module, Save-Module, Update-Module...}


PS C:\Git>  Get-PackageProvider

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.207        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag,...
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, I...
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent


PS C:\Git>  Get-PackageProvider -ListAvailable

Name                     Version          DynamicOptions
----                     -------          --------------
msi                      3.0.0.0          AdditionalArguments
msu                      3.0.0.0
NuGet                    2.8.5.207        Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag,...
PowerShellGet            1.1.2.0          PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, I...
PowerShellGet            1.0.0.1
Programs                 3.0.0.0          IncludeWindowsInstaller, IncludeSystemComponent

Find-* cmlets should support -allowPrerelease or support all version flags

During the bug bash for prerelease, we discovered a bug in the prerelease code. The bug was that when you do:

Find-Module RebroTest* -AllowPrerelease nothing shows up in the output.

After talking to Mani, this should throw an error because the design says that wildcards are not allowed with -AllowPrerelease (or with version flags at all) in Find,Install,Update-Module.

However, consider this scenario:

A user publishes a new package (tyleonhaTestPackage) with only a prereleased version (1.0.0-alpha1 for example). No stable releases.
A user does Find-Module and this shows everything that isn't a prerelease (tyleonhaTestPackage doesn't show up).
A user does Find-Module * -AllowPrerelease and this throws an error by design (tyleonhaTestPackage doesn't show up).

This means that currently, by design, a preleased package that has no stable version will not show up in Find-Module unless you explicitly specify the full name of the package and of course -AllowPrerelease. No prerelease results will show up in Find-Module with a wildcard.

I propose that we allow the -AllowPrerelease flag to be used with wildcards in Find-Module or allow wildcards to be used with all version strings.

NOTE: I don't think we should allow this in Install/Update-Module... too much risk there but Find-Module is just a search and this should be supported so that you can find modules that are prerelease that have no stable versions.

The flow would be:

Find-Module tyleonhaTest* -AllowPrerelease
Install-Module tyleonhaTestModule -AllowPrerelease

Publish-Module, Save-Module and Install-Module do not work with pre-release module, which depends on another pre-release module

We're trying to make a pre-release of our product which contains multiple modules, that depend on each other. We can successfully publish the first pre-release module which has no dependencies, but when we upload the next one, which depends on the we get an error saying that:
Publish-PSArtifactUtility : PowerShellGet cannot resolve the module dependency 'VMware.VimAutomation.Sdk' of the module
'VMware.VimAutomation.Common' on the repository 'PSGallery'. Verify that the dependent module 'VMware.VimAutomation.Sdk' is available in the
repository 'PSGallery'. If this dependent module 'VMware.VimAutomation.Sdk' is managed externally, add it to the ExternalModuleDependencies entry in the PSData section of the module manifest."

It turns out that the -AllowPreRelease parameter is not properly propagated down the stack. Even after we fixed Publish-Module locally and managed to upload all the modules Save-Module and Install-Module do not work for the same reason. Customers will only be able to download the first module, which has not dependencies.

Expected Behavior

Module should publish and install without errors.

Current Behavior

Publish-PSArtifactUtility : PowerShellGet cannot resolve the module dependency 'VMware.VimAutomation.Sdk' of the module
'VMware.VimAutomation.Common' on the repository 'PSGallery'. Verify that the dependent module 'VMware.VimAutomation.Sdk' is available in the
repository 'PSGallery'. If this dependent module 'VMware.VimAutomation.Sdk' is managed externally, add it to the ExternalModuleDependencies entry in the PSData section of the module manifest."

Possible Solution

-AllowPreRelease parameter should be properly propagated down the stack

Steps to Reproduce (for bugs)

Find-Module VMware.PowerCLI -AllowPrerelease | Install-Module

Context

We're trying to make a pre-release of our product which contains multiple modules, that depend on each other.

Your Environment

PS C:\windows\system32> $PSVersionTable

Name Value


PSVersion 5.1.15063.786
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.15063.786
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

PS C:\windows\system32> Get-Module -ListAvailable PowerShellGet,PackageManagement

Directory: C:\Program Files\WindowsPowerShell\Modules

ModuleType Version Name ExportedCommands


Script 1.1.7.0 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Binary 1.0.0.1 PackageManagement {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...
Script 1.6.0 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}
Script 1.0.0.1 PowerShellGet {Install-Module, Find-Module, Save-Module, Update-Module...}

PS C:\windows\system32> Get-PackageProvider

Name Version DynamicOptions


msi 3.0.0.0 AdditionalArguments
msu 3.0.0.0
NuGet 2.8.5.210 Destination, ExcludeVersion, Scope, SkipDependencies, Headers, FilterOnTag...
PowerShellGet 1.6.0.0 PackageManagementProvider, Type, Scope, AllowClobber, SkipPublisherCheck, ...
Programs 3.0.0.0 IncludeWindowsInstaller, IncludeSystemComponent

Why does Publish error handling check for a magic NugetApiKey?

In the error handling for Publish-PSArtifactUtility there is a test for $NugetApiKey -eq 'VSTS' which is driving me crazy.

Under what circumstances does that actually come up? Doesn't it require that users know to use "VSTS" as a magical API key, but not know why they should do so? I mean, if they knew what they were doing it, they would not get this error, right? So it seems this only happens if they coincidentally guess at the APIKey.

I appreciate the attempt, and the error message is very useful.

Perhaps you could just be match the $errorMsg? Or even just test for "visualstudio.com" in the URL instead?

One final thought: could that error message (and/or the web url) be updated to include instructions for registering the URL from the command line?

Proposal: use nuget api for publishing

Today, finding and installing modules goes through package management and nugetprovider code, but publishing a module shells out to nuget.exe or dotnet.exe. This introduces the whole 'bootstrapping' process, which is an extra hassle for end-users, especially when they have restrictions on network access. It also involves a surprising amount of code, including a lot of complications in the test code.

As an alternative, we could:

  • Add a build step which pulls down the nuget client .nupkgs
  • Ship those (coreclr and fullclr) inside the PowerShellGet package
  • Call into the API when we need to pack and push the package instead of running nuget via process.start

Advantages:

  • Remove bootstrapping altogether
  • Remove differences between versions of dotnet and nuget.exe such as recent confusion over hidden files

Potential issues:

  • oldest version of nuget.protocol nupkg is compiled against .net 4.6, but powershell 4 uses 4.5 - is that a problem?
  • Can we actually do this on all supported platforms? nano server?
  • This would mean loading .net assemblies into memory so update-module PowerShellGet would require a process restart to complete
  • Nuget.Client API is a mess and documentation is sparse to nonexistent

Publish-Module should support PSModuleInfo as input

From @heaths on November 2, 2015 22:32

I have a help file in my module named something like mydll.dll-help.xml and it works fine when in the module directory; however, after running publish-module it seems that file wasn't packaged and pulled down later with install-module. The file is listed in the module manifest in the FileList property.

See the 'msi' module in the gallery if you want to review the manifest.

Copied from original issue: OneGet/oneget#155

Input object support for Uninstall

Workaround

get-module IseSteroids -ListAvailable | Sort-Object -Property Version -Descending  | Select-Object -Last 1 | %{Write-verbose -message "uninstalling $($_.name) $($_.version)" -Verbose ;
>> Uninstall-Module -Name $_.name -RequiredVersion $_.Version -force
>> }
VERBOSE: uninstalling ISESteroids 2.3.0.64

Repro Frequency

100%

Repro Steps

get-module IseSteroids -ListAvailable | Sort-Object -Property Version -Descending  | Select-Object -Last 1 | select name, version
Name        Version
----        -------
ISESteroids 2.3.0.64
get-module IseSteroids -ListAvailable | Sort-Object -Property Version -Descending  | Select-Object -Last 1 | Uninstall-Module -force -Verbose
WARNING: The version '2.4.0.44' of module 'ISESteroids' is currently in use. Retry the operation after closing the applications.
PackageManagement\Uninstall-Package : Module 'ISESteroids' is in currently in use.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1803 char:21
+ ...        $null = PackageManagement\Uninstall-Package @PSBoundParameters
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power...ninstallPackage:UninstallPackage) [Uninstall-Package], Exception
    + FullyQualifiedErrorId : ModuleIsInUse,Uninstall-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.UninstallPackage

Expected

It should attempt to uninstall the module I pipe to the cmdlet

Actual

It tries to uninstall the most recent module

Save-Module fails on WS2012R2 + WMF5 + Latest PSGet/PM

Some environments with the setup in the title fail. Others are unable to repro.

Repro

Save-Module on certain WS2012R2 + WMF5 + Latest PSGet/PM environments fails. AdministratorRightsNeededOrSpecifyCurrentUserScope appears to be in PSGet, though this seems to be related to contract issues between PSGet and PM, possibly due to a bad previous installation.

Steps

  1. Install WMF for PS4 on Server 2012 R2
  2. Save-Module PowerShellGet
  3. Install latest PSGet and PackageManagement (this happens on 1.1.4 and 1.1.3 at least)
  4. save-module packagemanagement -requiredversion 1.1.3.0 -path $somePath (also tried xjea)

Expected results

Package is saved or a real error is shown

Actual results

WARNING: The property 'AdministratorRightsNeededOrSpecifyCurrentUserScope' cannot be found on this object. Verify that
the property exists.
PackageManagement\Save-Package : Unable to save the module 'PackageManagement'.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:1616 char:21

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.