用 Get-Command 发现 PowerShell 命令
PowerShell 原生地回答“这个命令存在吗、哪个会生效?”——它能同时看到 cmdlet、别名、函数和可执行文件。
运行 `Get-Command python -All` 按优先级列出所有匹配项;查看 Source/Path 即可知道真正执行的是哪一个。
01命令
命令
$ Get-Command python -All02作用说明
Get-Command 会搜索所有命令来源——模块、别名、函数和 PATH 中的可执行文件,因此能发现 where.exe 看不到的冲突(比如配置文件里的别名遮住了真实程序)。配合通配符它还是个发现工具:`Get-Command -Noun Firewall` 或 `Get-Command *dns*` 能翻出你不知道的相关 cmdlet。加 -Syntax 可查看 cmdlet 的参数列表,-ListImported / -Module 则把搜索限定到已加载的命令。
03风险
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- Get-Command - PowerShell依据: SS64 shows Get-Command usage for discovering cmdlets, aliases, and executables with wildcards and -ParameterType filters.
- Get-Command | Microsoft Learn依据: Microsoft documents Get-Command returning command info including CommandType, Source, Path, and the -All switch to list all matches.
最后验证: 2026-09-17 · 分类: 开发者