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

Install-package docker fails : 'Get-WindowsFeature' is not recognized #26

Open
erichexter opened this issue Mar 29, 2017 · 14 comments
Open

Comments

@erichexter
Copy link

erichexter commented Mar 29, 2017

cc/ @jayshah-msft @taylorb-microsoft @friism

Repro steps:

I am getting an exception on this line: https://github.com/OneGet/MicrosoftDockerProvider/blob/developer/DockerMsftProvider.psm1#L586

  1. create a new vm, install windows 2016 standard with Desktop experience, run windows update.
  2. add-windowsfeature containers
  3. reboot
  4. Install-Module -Name DockerMsftProvider -Repository PSGallery -Force
  5. Install-Package -Name docker -ProviderName DockerMsftProvider

Expected Result:
Docker and Docker Engine are install on server

Actual Result:
PS C:> Install-Package -Name docker -ProviderName DockerMsftProvider -Force
Install-Package : The term 'Get-WindowsFeature' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1

  • Install-Package -Name docker -ProviderName DockerMsftProvider -Force
  •   + CategoryInfo          : InvalidOperation: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package],
     Exception
      + FullyQualifiedErrorId : FailedToDownload,Install-Package,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallP
     ackage
    
@erichexter
Copy link
Author

Whats strange is if I execute an install-module ServerManager I still get this error.

@thecloudtaylor
Copy link
Collaborator

@enderb-ms you where looking into to something similar correct?

@erichexter
Copy link
Author

I created some additional Data Center and Standard VMs and I was not able to repro this. Its only happening on one Standard Edition VM.

@erichexter erichexter changed the title Install-package docker fails on windows server 2016 standard vm Install-package docker fails : 'Get-WindowsFeature' is not recognized Apr 13, 2017
@erichexter
Copy link
Author

erichexter commented Apr 13, 2017

cc/ @enderb-ms @taylorb-microsoft

I found the issue. I don't understand exactly what is happening by one get but under the hood this is what I believe is happening.

The Install-package command invokes a new runspace or powershell instance, in the instance only the default modules are loaded. Inside this package there is a call to Get-WindowsFeature. When this is called, powershell attempts to resolve the method. To do this is searches the $env:PSModulePath for modules that contain this method. Apparently it does not search all of the paths in this environment variables, it only searches some of them. I had a user environment variable, which boxstarter created , I deleted that. Then I put the path that contains the ServerManager modules (the module which contains get-windowsfeature) to the front of this environment variable.
i.e.
C:\Windows\system32\WindowsPowerShell\v1.0\Modules

After that, I started a new powershell session and then the package was able to install correctly.

@dermeister0
Copy link

dermeister0 commented May 22, 2017

I have only default module paths, it's clean Windows Server 2016.

PS C:\Users\Administrator> $env:PSModulePath
C:\Users\Administrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules

I copied C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ServerManager to C:\Users\Administrator\Documents\WindowsPowerShell\Modules as a work-around.

@dermeister0
Copy link

dermeister0 commented May 22, 2017

It does not work in 32-bit PowerShell. It's some strange file system virtualization.

PS C:\Users\Administrator> [System.IntPtr]::Size
8
PS C:\Users\Administrator> $env:PSModulePath
C:\Users\Administrator\Documents\WindowsPowerShell\Modules;C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system3
2\WindowsPowerShell\v1.0\Modules
PS C:\Users\Administrator> Import-Module ServerManager
PS C:\Users\Administrator> (gci 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules').Length
78
PS C:\Users\Administrator> [System.IntPtr]::Size
4
PS C:\Users\Administrator> $env:PSModulePath
C:\Program Files\WindowsPowerShell\Modules;C:\Users\Administrator\Documents\WindowsPowerShell\Modules;C:\Program Files (
x86)\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules
PS C:\Users\Administrator> Import-Module ServerManager
Import-Module : The specified module 'ServerManager' was not loaded because no valid module file was found in any
module directory.
At line:1 char:1
+ Import-Module ServerManager
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (ServerManager:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand

PS C:\Users\Administrator> (gci 'C:\Windows\System32\WindowsPowerShell\v1.0\Modules').Length
56

@divya1231
Copy link

I was using powershell x86 when i got this error. Switching to Powershell , resolved the problem

@friism
Copy link
Contributor

friism commented Jun 21, 2017

The script should check for whether it's in a 32bit console then

@friism
Copy link
Contributor

friism commented Sep 7, 2017

cc @johnstep in case you end up fiddling with the provider

@romulomadu-zz
Copy link

romulomadu-zz commented Apr 24, 2018

Hi, I'm having the same problem:

Install-WindowsFeature : The term 'Install-WindowsFeature' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct
and try again.
At line:1 char:9
+ $null = Install-WindowsFeature containers
+         ~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-WindowsFeature:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

But, if I followed right what @erichexter it not worked for me.

Someone knows an alternative? There is a way to install it manually?

@MirzaSikander
Copy link

Getting this on Windows Enterprise host.

@NickiSibbern
Copy link

Getting this on a windows server 2016 LTS
NT 10.0.14393
Powershell 5.1

had to add C:\Windows\system32\WindowsPowerShell\v1.0\Modules to my PsModulePath as suggested by @erichexter which solved the issue.

@wolffberg
Copy link

wolffberg commented Jul 23, 2018

Check if another module or function is overwriting the default Get-WindowsFeature. In our case we had Carbon (http://get-carbon.org) installed which took precedence over the default cmdlet.

@anarsen
Copy link

anarsen commented Jul 31, 2018

I'm using the DockerProvider through DSC, and figured I'd just set the PSModulePath env variable through DSC as well.

Works like a charm.

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

10 participants