简体   繁体   中英

Why do I get an error running Get-WindowsCapability in PowerShell ISE on Windows Server 2012 r2?

I am running the PowerShell ISE on a Windows Server 2012 r2 machine. When I run the following:

Get-WindowsCapability

I get the following error:

Get-WindowsCapability : The term 'Get-WindowsCapability' 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

  • Get-WindowsCapability
  •  + CategoryInfo : ObjectNotFound: (Get-WindowsCapability:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException

Am I missing a PowerShell package? How do get this feature working?

Thanks, JohnB

Get-WindowsCapability is a cmdlet from the DISM module.

DISM was deployed natively with Server 2012 R2, but depending on the version of PowerShell or other configuration settings (like where your Windows partition is setup or image specific customizations), sometimes we find that we need to import the module before using it, like so:

Import-Module DISM 

#or, to see which commands are in the module
Import-Module DISM -Verbose

If this fails, double check that it wasn't removed somehow. For instance, does it appear when you run the following?

Get-Module DISM -ListAvailable

If it doesn't appear, then it seems the module was removed and maybe the Windows component. No worries, we can get it back with the module too by installing the Windows Automated Deployment Kit (ADK), found here .

Update : you may find the module under this path as well

C:\\Program Files (x86)\\Windows Kits\\10\\Assessment and Deployment Kit\\Deployment Tools\\ .
The module file to import would be under the x86\\DISM folder or x64\\DISM , and named dism.psm1

This command seems not available in Server 2012 verson. https://docs.microsoft.com/en-us/powershell/module/dism/?view=winserver2012r2-ps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM