如何从模块中检索可用命令? [英] How do I retrieve the available commands from a module?

查看:12
本文介绍了如何从模块中检索可用命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

要知道机器上有哪些 PowerShell 模块可用,我使用命令

To know which PowerShell modules are available on a machine I use the command

Get-Module -ListAvailable

这将返回一个包含模块类型、-name 和导出命令的列表.但导出的命令始终为空,仅显示 {}.为什么不显示?

This returns a list with module-type, -name and the exported commands. But the exported commands are always empty and just displaying {}. Why is this not displayed?

我是否必须使用其他参数或是否有其他 cmdlet 或方法来检索可用命令?

Do I have to use another parameter or is there another cmdlet or method to retrieve the available commands?

推荐答案

如果模块未加载,则导出的命令不可用.您需要先加载模块,然后执行 Get-命令:

Exported commands are not available if the module is not loaded. You need to load the module first and then execute Get-Command:

Import-Module -Name <ModuleName>
Get-Command -Module <ModuleName>

这篇关于如何从模块中检索可用命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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