You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用Out-GridView时-OutputMode与-PassThru参数冲突报错求助

解决Out-GridView参数绑定异常问题

报错原因分析

  1. 参数集互斥:Out-GridView的-OutputMode与-PassThru属于互斥参数集,无法同时使用。当指定-OutputMode Multiple时,该参数已经会将选中的多个对象输出到后续管道,无需额外添加-PassThru。
  2. 符号格式错误:代码中的–PassThru、–Verbose、–WhatIf使用了中文全角破折号,PowerShell无法识别为合法的参数前缀,必须替换为英文半角破折号-。

修正后的代码

$file_dublicates | Out-GridView -Title "Select files" -OutputMode Multiple | Remove-Item -Verbose -WhatIf

补充说明

如果习惯用-PassThru实现输出,可去掉-OutputMode参数(此时默认选中单个对象,按住Ctrl键可多选),代码如下:

$file_dublicates | Out-GridView -Title "Select files" -PassThru | Remove-Item -Verbose -WhatIf

内容的提问来源于stack exchange,提问作者PCTech

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.14 04:10:29