Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change commands from *-Certificate #168

Closed
tradiuz opened this issue Sep 29, 2016 · 13 comments
Closed

Change commands from *-Certificate #168

tradiuz opened this issue Sep 29, 2016 · 13 comments

Comments

@tradiuz
Copy link

tradiuz commented Sep 29, 2016

PS 5.1 brings in the pki module which includes the following cmdlets:

get-command -Module pki

CommandType     Name                                               Version    Source
-----------     ----                                               -------    ------
Cmdlet          Add-CertificateEnrollmentPolicyServer              1.0.0.0    pki
Cmdlet          Export-Certificate                                 1.0.0.0    pki
Cmdlet          Export-PfxCertificate                              1.0.0.0    pki
Cmdlet          Get-Certificate                                    1.0.0.0    pki
Cmdlet          Get-CertificateAutoEnrollmentPolicy                1.0.0.0    pki
Cmdlet          Get-CertificateEnrollmentPolicyServer              1.0.0.0    pki
Cmdlet          Get-CertificateNotificationTask                    1.0.0.0    pki
Cmdlet          Get-PfxData                                        1.0.0.0    pki
Cmdlet          Import-Certificate                                 1.0.0.0    pki
Cmdlet          Import-PfxCertificate                              1.0.0.0    pki
Cmdlet          New-CertificateNotificationTask                    1.0.0.0    pki
Cmdlet          New-SelfSignedCertificate                          1.0.0.0    pki
Cmdlet          Remove-CertificateEnrollmentPolicyServer           1.0.0.0    pki
Cmdlet          Remove-CertificateNotificationTask                 1.0.0.0    pki
Cmdlet          Set-CertificateAutoEnrollmentPolicy                1.0.0.0    pki
Cmdlet          Switch-Certificate                                 1.0.0.0    pki
Cmdlet          Test-Certificate                                   1.0.0.0    pki

Obviously this overlap causes issues. I suggest moving to a ACMECertificate noun in the verb-noun cmdlet name or something similar.

@bseddon
Copy link
Contributor

bseddon commented Oct 1, 2016

All the commands are already of the form:

Get-ACMECertificate
New-ACMEIdentifier

etc. The prefix is set in the psd file on line 25.

Can you explain a bit more about the issue you are reporting?

Maybe you are trying to use Install-Module instead of Import-Module?

@kittenclubber
Copy link

This is what he means:
From the PSGallery package acmesharp:

`
Windows PowerShell
Copyright (C) 2016 Microsoft Corporation. All rights reserved.

Loading personal and system profiles took 883ms.
PS C:\work> Install-Package ACMESharp

The package(s) come(s) from a package source that is not marked as trusted.
Are you sure you want to install software from 'PSGallery'?
[Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): y
Install-Package : A command with name 'Get-Certificate' is already available on this system. This module 'ACMESharp'
may override the existing commands. If you still want to install this module 'ACMESharp', use -AllowClobber parameter.
At line:1 char:1

  • Install-Package ACMESharp
  • - CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
      Exception
    - FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
      ageManagement.Cmdlets.InstallPackage
      `
    

@bseddon
Copy link
Contributor

bseddon commented Oct 25, 2016

Why are you using install-package instead of Import-Module? The instructions on the Quick Start guide use the Import-Module command. This works for me.

@ebekker
Copy link
Owner

ebekker commented Oct 25, 2016

Hmm, this is a bit of dilemma, he's installing the package from the PSGallery to the local machine (he needs to install the package locally before he can import it to make use of it).

The problem is that the Install-Package is looking at the naked cmdlet names without taking into consideration the DefaultCommandPrefix that is defined in the containing module. In my opinion this is an oversight of the Install-Package routine.

While technically this is true (ACMESharp does override an existing command), whenever you import this or any other module (Import-Module), you always have the option of specifying the -Prefix parameter to define your own prefix to the noun-part of a cmdlet. Further you have the option of specifying the -NoClobber switch which guarantees that no cmdlet will be loaded that has the same name as an existing name in the current session.

@kittenclubber
Copy link

Yes while it does still work like you said its a dilemma..

..It will prompt on every machine with powershell >= 5 which is the main thing... with server 2016 base&nano / windows 10 + by default unless altered at one side or the other. In any case thanks for all the work for making this available to us :)

@ebekker
Copy link
Owner

ebekker commented Oct 25, 2016

Actually, I think misspoke, @bseddon was on the right track -- if you are installing from the PowerShell Gallery, you shouldn't be using Install-Package -- you should be using Install-Module, as in:

Install-Module -Name ACMESharp

When I run this on a PS5 host, I don't get any warnings, and I confirmed the PKI module is in place and there are no conflicts.

Install-Package is used as a "front-end" for a generic packaging system of systems, an aggregator for things like Chocolatey.

@kittenclubber
Copy link

yeah just tested that thanks to both of you!

@jozefizso
Copy link

The suggested use of Install-Module does not work either on Windows 10.

PS > Install-Module -Name ACMESharp
PackageManagement\Install-Package : A command with name 'Get-Certificate' is already available on this system. This module 'ACMESharp' may override the existing commands. If you still want to install
this module 'ACMESharp', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1661 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
PS > $PSVersionTable

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

@ghost
Copy link

ghost commented Dec 30, 2016

I came to report the same issue ae jozefizso under current build of Windows 10. I'm also looking for a workaround recommendation. Should I perhaps try -AllowClobber or -Prefix?

PS C:\WINDOWS\system32> Install-Module -Name ACMESharp

NuGet provider is required to continue
PowerShellGet requires NuGet provider version '2.8.5.201' or newer to interact with NuGet-based repositories. The NuGet provider must be available in 'C:\Program Files\PackageManagement\ProviderAssemblies' or
'C:\Users\ssargent\AppData\Local\PackageManagement\ProviderAssemblies'. You can also install the NuGet provider by running 'Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force'. Do you want PowerShellGet to install and import the NuGet provider now?
[Y] Yes  [N] No  [S] Suspend  [?] Help (default is "Y"): y

Untrusted repository
You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'?
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "N"): y
PackageManagement\Install-Package : A command with name 'Get-Certificate' is already available on this system. This module 'ACMESharp' may override the existing commands. If you still want to install this module 'ACMESharp', use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage

PS C:\WINDOWS\system32>  $PSVersionTable

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

@Matty666
Copy link

Matty666 commented Apr 4, 2017

I've just come across this issue, is there any advice about what to do? Is it ok to use -AllowClobber?

@ebekker
Copy link
Owner

ebekker commented Apr 11, 2017

Apparently a known problem with PowerShellGet.

@ebekker
Copy link
Owner

ebekker commented Apr 11, 2017

Duplicate of #159.

@ebekker
Copy link
Owner

ebekker commented Aug 23, 2017

See this article for details about this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants