我经常使用
ii .
在 PowerShell 中打开 Windows 资源管理器中的当前目录。这过去一直有效,但现在没有任何反应。
Invoke-Item
cmdlet 仍然有效。执行 ii somefile.txt
在文本编辑器中打开该文件。但是目录不再起作用了。
此外 start .
不起作用。使用 explorer .
确实有效。
运行
Trace-Command -Name ParameterBinding {ii .} -PSHost
返回
DEBUG: ParameterBinding Information: 0 : BIND NAMED cmd line args [Invoke-Item]
DEBUG: ParameterBinding Information: 0 : BIND POSITIONAL cmd line args [Invoke-Item]
DEBUG: ParameterBinding Information: 0 : BIND arg [.] to parameter [Path]
DEBUG: ParameterBinding Information: 0 : Binding collection parameter Path: argument type [String], parameter type [System.String[]],
collection type Array, element type [System.String], no coerceElementType
DEBUG: ParameterBinding Information: 0 : Creating array with element type [System.String] and 1 elements
DEBUG: ParameterBinding Information: 0 : Argument type String is not IList, treating this as scalar
DEBUG: ParameterBinding Information: 0 : Adding scalar element of type String to array position 0
DEBUG: ParameterBinding Information: 0 : BIND arg [System.String[]] to param [Path] SUCCESSFUL
DEBUG: ParameterBinding Information: 0 : BIND cmd line args to DYNAMIC parameters.
DEBUG: ParameterBinding Information: 0 : MANDATORY PARAMETER CHECK on cmdlet [Invoke-Item]
DEBUG: ParameterBinding Information: 0 : CALLING BeginProcessing
DEBUG: ParameterBinding Information: 0 : CALLING EndProcessing
运行
Trace-Command -Name CommandDiscovery {ii .} -PSHost
返回
DEBUG: CommandDiscovery Information: 0 : Looking up command: ii
DEBUG: CommandDiscovery Information: 0 : Alias found: ii Invoke-Item
DEBUG: CommandDiscovery Information: 0 : Cmdlet found: Invoke-Item Microsoft.PowerShell.Commands.InvokeItemCommand,
Microsoft.PowerShell.Commands.Management, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
我想可能存在文件关联问题或其他问题。但我无法弄清楚 Invoke-Item
实际调用的是什么或如何更改它。
我怎样才能让它重新工作?
最佳答案
很难弄清楚为什么它不再适合你,但为什么不使用在 powershell 和 cmd 中相同的替代方法:
start .
(explorer .
也可以)
如果 ii .
很重要,请尝试重新启动 Powershell 控制台和/或计算机。也尝试做 ii 。 -whatif
看看你是否得到任何关于为什么它不再起作用的线索。
关于Powershell Invoke-Item 不再适用于在资源管理器中打开目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10141357/