PowerShell Add-WindowsFeature unrecognized
I’ve basically got a third-party agent software which allows me to execute PowerShell as LocalSystem. This allows me to easily run remote PowerShell commands without WinRM etc.
The problem that i’m running into is that on some servers i’m not able to perform get-WindowsFeature or Add-WindowsFeature.
An example of how i’m trying to achieve this is here:
The output is as such:
If I type those same commands into a PowerShell window, or call PowerShell.exe directly, it returns. I’m trying to figure out what we’re not doing right within the application, but i’m the most familiar person with PowerShell here.
Is there something special I need to do to load those cmdlets? Get-Module doesn’t show anything, oddly.
In response to JBSmith:
Yessir — looks like 2.0. Here are the results of the commands you mentioned
I also noticed that GCM | ? < $_.ModuleName -eq 'ServerManager' >returns nothing when I run it through there, but through a normal PS window it returns a command list as expected.
Командлет PowerShell Install-WindowsFeature вызывается из ошибок C # и не отображается в коллекциях команд
Я пытаюсь установить новые функции в системе Windows 2012 через Powershell и С#. Я получаю эту ошибку при попытке вызвать командлет Install-WindowsFeature .
Термин «Install-WindowsFeature» не распознается как имя командлет, функция, script файл или операционная программа.
Я могу вызывать другие командлеты, хотя С# и даже некоторые другие. Я сделал Get-Command и Install-WindowsFeature , Remove-WindowsFeature , а Get-WindowsFeatures не указан. но около 980 других.
Любая подсказка, почему я не смог бы вызвать этот командлет из моей программы на С#, но когда я перейду в Powershell, он называет это просто отлично?
Install windowsfeature не распознано как имя командлета
I get the following error: No spelling error in ComputerName
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:1
+ Install-WindowsFeature -Name WindowsPowerShellWebAccess -ComputerName .
+
+ CategoryInfo : ObjectNotFound: (Install-WindowsFeature:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Install-package docker fails : ‘Get-WindowsFeature’ is not recognized #26
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
The text was updated successfully, but these errors were encountered:
@enderb-ms you where looking into to something similar correct?
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.
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.
I have only default module paths, it’s clean Windows Server 2016.
I copied C:\Windows\System32\WindowsPowerShell\v1.0\Modules\ServerManager to C:\Users\Administrator\Documents\WindowsPowerShell\Modules as a work-around.