Get windowsfeature ошибка

  • Remove From My Forums
  • Question

  • What happened to the get-windowsfeature cmdlet?? It was working a few days ago, receiving the error message below. Tested it on several PC’s running Windows 10.

    get-windowsfeature : 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 a
    gain.
    At line:1 char:1
    + get-windowsfeature
    + ~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : ObjectNotFound: (get-windowsfeature:String) [], CommandNotFoundException
        + FullyQualifiedErrorId : CommandNotFoundException

I have an windows form application in which I want run power shell command.

Runspace _runspace = null;
Pipeline _pipeline = null;
Runspace _runspaceConfig = null;
_runspace = RunspaceFactory.CreateRunspace();
_runspaceConfig = RunspaceFactory.CreateRunspace();
_runspaceConfig.Open();
_pipeline = _runspaceConfig.CreatePipeline();
_pipeline.Commands.AddScript("Set-ExecutionPolicy Unrestricted");
_pipeline.Invoke();
InitialSessionState iss = InitialSessionState.CreateDefault();
iss.ImportPSModule(new string[] { "servermanager" });
_runspace = RunspaceFactory.CreateRunspace(iss);
_runspace.Open();
Collection<PSObject> response = new Collection<PSObject>();
RunspaceConfiguration rc = RunspaceConfiguration.Create();
var runspaceConfig = RunspaceFactory.CreateRunspace(rc);
runspaceConfig.Open();
var pipeline = runspaceConfig.CreatePipeline();
pipeline.Commands.AddScript("Get-WindowsFeature -Name RDS-RD-Server");
response = pipeline.Invoke();

I am running application in 64bit on windows server 2012R2
compiling in x64. In VS go to Project > Properties > Build — Platform Target = x64.
application throw error » 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.»
I need help to solve issue.

When i type the command Get-WindowsFeature in PowerShell 5 it displays this error, and I don’t know why!

Get-WindowsFeature: The term "Get-WindowsFeature" is not recognized as a cmdlet name,
function, script file or executable program. Check the spelling of the name, or if a path
access exists, verify that the path is correct and try again.
To the character Line: 1: 1
+ Get-WindowsFeature
+ ~~~~~~~~~~~~~~~~~~
     + CategoryInfo: ObjectNotFound: (Get-WindowsFeature: String) [], CommandNotFoundException
     + FullyQualifiedErrorId: CommandNotFoundException

enter image description here

Mathias R. Jessen's user avatar

asked Feb 13, 2018 at 14:26

mohammed zine's user avatar

Get-WindowsFeature is not part of PowerShell 5, but of the Server Manager module, which is either not installed or loaded, because the error message clearly states, that the command you trying to execute is not available.

Use Import-Module ServerManager to import it, or Import-Module -ListAvailable to see if it’s even installed.

answered Feb 13, 2018 at 14:33

vrdse's user avatar

vrdsevrdse

2,91910 silver badges20 bronze badges

2

make sure that you not trying to access Get-ImportModule through Powershell(x86). It’s not there. Use the regular Powershell and you will be fine.

answered Nov 4, 2018 at 10:44

geets's user avatar

get-windowsfeature : The given key was not present in the dictionary

When you run the get-windowsfeature cmdlet in PowerShell on Windows Server 2012 you may see the following error

get-windowsfeature : The given key was not present in the dictionary.

At line:1 char:1
+ get-windowsfeature
+ ~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Get-WindowsFeature], KeyNotFoundException
    + FullyQualifiedErrorId : System.Collections.Generic.KeyNotFoundException,Microsoft.Windows.ServerManager.Commands
   .GetWindowsFeatureCommand

This seems to occur if there is a problem in the following registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ServerManager\ServicingStorage\ServerComponentCache

As this is just a cache registry key you can try renaming the key to ServerComponentCache.old and then re-running the PowerShell command or refreshing the view in server manager.

This recreates the key and rebuilds the server feature information.

— While you’re here —
Why not check out our Windows Server Documentation and Audit Tool?

Popular posts from this blog

Windows Server 2016, 2019, 2022, Windows 10 and Windows 11: Date and time «Some settings are managed by your organization».

Image

When you’re using the new «Modern» date and time settings in Windows Server 2016, 2019, 2022, Windows 10 and Windows 11 you may find that you can’t set the correct date and time and the value «Some settings are managed by your organization». — While you’re here — Why not check out our Windows Server Documentation and Audit Tool? The simplest way around this is to go back to the proper control panel using Start, Run, «Control.exe» and searching for «Set the date».  Within here you can set the date and time manually as required If you try and click the Change time zone button you may again get access denied… To resolve this open an elevated command prompt by right clicking the command prompt and selecting Run as Administrator  From there run the command rundll32.exe shell32.dll,Control_RunDLL timedate.cpl This will open the Data and Time control panel app elevated as an Administrator.

TFTPD32 or TFTPD64 reports Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions.

Image

When you start the trivial FTP (TFTP) server application TFTPD32 or TDTPD64 you may see the following error Bind error 10013 An attempt was made to access a socket in a way forbidden by its access permissions. This can be because another application is using this port. The easiest way to check if (and which) application is using the port is as administrator run an elevated command prompt and enter netstat -anb > ports.txt Then open ports.txt in Notepad and search for :69, you’ll quickly be able to see the process using the required port — While you’re here — Why not check out our Windows Server Documentation and Audit Tool?

Enable function lock for F1-F12 on HP ZBook mobile workstations

Image

When you press the function keys on a HP ZBook mobile workstation you may find that they don’t operate as expected. This is because of function lock, if you hold the fn key the function keys work as expected. You can lock the function keys on as described in this document. https://support.hp.com/gb-en/document/c02035108 However there are two things to note Firstly following a BIOS upgrade (which occurs automatically if you have the preinstalled HP software still installed) you may lose your locked function keys and have to reapply.   Secondly the HP documentation states you press the fn lock and fn keys at the same time as per the image below from the page.  While you’re here — Why not check out our Windows Server Documentation and Audit Tool? This is not the case, you need to press and hold the fn key, and then tap the fn lock key to toggle function lock, not an obvious thing when you start work first thing in the morning and are hammering the function keys try

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

Open

erichexter opened this issue

Mar 29, 2017

· 14 comments

Comments

@erichexter

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

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

@thecloudtaylor

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

@erichexter

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

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

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

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

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

@friism

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

@friism

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

@romulomadu-zz

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

Getting this on Windows Enterprise host.

@NickiSibbern

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

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

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.

Понравилась статья? Поделить с друзьями:
  • Genio робот пылесос ошибка е15
  • Geometry dash exe системная ошибка отсутствует msvcp100 dll
  • Genymotion ошибка unable to start the virtual device
  • Genio пылесос ошибка e41
  • Geometry dash exe ошибка приложения