为什么在 Windows Server 2012 r2 上的 PowerShell ISE 中运行 Get-WindowsCapability 时出现错误? [英] Why do I get an error running Get-WindowsCapability in PowerShell ISE on Windows Server 2012 r2?

查看:28
本文介绍了为什么在 Windows Server 2012 r2 上的 PowerShell ISE 中运行 Get-WindowsCapability 时出现错误?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Windows Server 2012 r2 机器上运行 PowerShell ISE.当我运行以下命令时:

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

Get-WindowsCapability

我收到以下错误:

Get-WindowsCapability :术语Get-WindowsCapability"不是被识别为 cmdlet、函数、脚本文件或可操作的名称程序.检查名称的拼写,或者是否包含路径,验证路径是否正确,然后重试.在行:1 字符:1

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

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

我是否缺少 PowerShell 软件包?如何使此功能正常工作?

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

谢谢,约翰

推荐答案

Get-WindowsCapability 是来自 DISM 模块的 cmdlet.

Get-WindowsCapability is a cmdlet from the DISM module.

DISM 是随 Server 2012 R2 本地部署的,但根据 PowerShell 的版本或其他配置设置(例如 Windows 分区的设置位置或特定于图像的自定义),有时我们发现我们需要在使用之前导入模块,像这样:

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

如果它没有出现,那么似乎该模块已被删除,并且可能是 Windows 组件.不用担心,我们也可以通过安装 Windows 自动部署工具包 (ADK) 将其带回模块,在此处找到.

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\.
要导入的模块文件将位于 x86\DISM 文件夹或 x64\DISM 下,并命名为 dism.psm1

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

这篇关于为什么在 Windows Server 2012 r2 上的 PowerShell ISE 中运行 Get-WindowsCapability 时出现错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆