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

Use of built-in PowerShell commands should be renamed or removed #22

Open
wsmelton opened this issue Jun 9, 2018 · 4 comments
Open

Comments

@wsmelton
Copy link

wsmelton commented Jun 9, 2018

The module contains Import-Certificate which is a built-in command for Windows PowerShell in Windows 8 and above. So trying to install this module fails with the below error due to this.

It would better to either remove the command from the module or rename it where it will not overwrite the local command.

06-08 21:26:13 C:\WINDOWS\system32> install-module pssoftware
PackageManagement\Install-Package : The following commands are already available on this system:'Import-Certificate'.
This module 'PSSoftware' may override the existing commands. If you still want to install this module 'PSSoftware',
use -AllowClobber parameter.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters
+                      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
   Exception
    + FullyQualifiedErrorId : CommandAlreadyAvailable,Validate-ModuleCommandAlreadyAvailable,Microsoft.PowerShell.Pack
   ageManagement.Cmdlets.InstallPackage
@corbob
Copy link
Collaborator

corbob commented Jun 9, 2018

hmmmmm. It seems that on Windows 10 Write-Log is also included (unless I've inadvertently installed PSDesiredStateConfiguration without realizing it).

I know for creating a temp file I was cognizant of the fact that some versions of PowerShell include it, and others didn't. I'll have a think about how to handle this, it may be that we don't need this command on newer PowerShell.

@wsmelton
Copy link
Author

wsmelton commented Jun 9, 2018

Dbatools we support 3.0 and higher and have certificate commands. Chrissy wrote those and I'm not sure if she is using built in commands for them or not.

@corbob
Copy link
Collaborator

corbob commented Jun 12, 2018

It looks like all of the dbatools functions have a prefix of dba (well most of them do, and the few that don't wouldn't overlap from what I can tell). This might be what to do for our Import-Certificate.

A nice pester test might be to wrap this command up so that they all return False:

get-command -Module PSSoftware | % { write-host "$_ : $((command $_.name -all | ? Source -like 'Microsoft.PowerShell.*' | measure | select -expandproperty count) -gt 0)" }

Although that being said, I'm not entirely sure why I don't have Import-Certificate on my Windows 10 1803 system...

@wsmelton
Copy link
Author

I'm on 1803 and it exist on my machine.

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

2 participants