You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

输入‘vm’触发Get-VM命令的映射来源排查及移除方法求助

‘vm’触发Get-VM命令的映射来源排查及移除方法求助

我本来想从当前环境启动vim,先确认了vim的位置:

PS C:\temp> get-command vim | select name,source

Name    Source
----    ------
vim.bat C:\Users\noam\AppData\Local\Microsoft\WindowsApps\vim.bat

结果手滑输成了vm而不是vim,这下可把我搞懵了:

C:\temp>pwsh -noprofile
PowerShell 7.4.1
PS C:\temp> vm
Get-VM: 29-Mar-24 16:28:14      Get-VM          You are not currently connected to any servers. Please connect first using a Connect cmdlet.
PS C:\temp> get-command vm
Get-Command: The term 'vm' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
PS C:\temp> get-alias vm
Get-Alias: This command cannot find a matching alias because an alias with the name 'vm' does not exist.
PS C:\temp> cmd /c where vm
INFO: Could not find files for the given pattern(s).

我想找到并移除这个把vm映射到VMware PowerCLI的Get-VM的配置,目前确认Get-VM来自VMware模块:

PS C:\temp> get-command get-vm | select Name,Source

Name   Source
----   ------
Get-VM VMware.VimAutomation.Core

我肯定漏掉了什么简单的点。我本来以为where.exe能找出路径上所有相关的东西,但就算把$env:PATH设为$null,这个问题还是存在。

虽然我可以用Set-Aliasvm显式定义成一个不存在的命令来临时解决,但我想搞明白为什么输入vm会出现这种情况——正常输入不存在的命令应该是下面这样的提示啊:

PS C:\temp> doesnotexist
doesnotexist: The term 'doesnotexist' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

而且不管有没有显式导入VMware.VimAutomation.Core模块,这个现象都能重现。有没有大佬能帮我理清楚这背后的原因,以及怎么彻底移除这个奇怪的映射?

备注:内容来源于stack exchange,提问作者noam

火山引擎 最新活动