mus*_*que 3 windows powershell shell-scripting
当我尝试执行以下 PowerShell 命令时,出现错误。
命令 :
*PS 证书:\currentuser\authroot> gci | where 主题-like “ UTN ”*
错误如下:
Where-Object : 无法绑定参数“FilterScript”。无法将“System.String”类型的“subject”值转换为“System.Management.Automation.ScriptBlock”类型。在行:1 字符:12 + gci | 其中 <<<< 主题 -类似“ UTN ”+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException +fullyQualifiedErrorId :CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
我正在使用 Windows PowerShell ISE。
高度赞赏可行的解决方案
看起来您使用的是 PowerShell Vs.2,该版本不支持新的where syntax.
在 PowerShell 的版本 1 和 2 中使用:
gci | where {$_.subject -like "UTN"}
Run Code Online (Sandbox Code Playgroud)
您需要在表达式周围放置大括号并引用带有$_.前缀的任何属性。
| 归档时间: |
|
| 查看次数: |
19359 次 |
| 最近记录: |