Cam*_*mpo 2 powershell windows-7 command-line-interface
任何想法我在这里做错了什么?我从教程中复制了此脚本并收到此错误....
PS C:\Windows\system32> Get-Service | Where-Object ($_.status -eq "running")
Where-Object : Cannot bind parameter 'FilterScript'. Cannot convert value "False" to type "System.Management.Automation
.ScriptBlock". Error: "Invalid cast from 'System.Boolean' to 'System.Management.Automation.ScriptBlock'."
At line:1 char:27
+ Get-Service | Where-Object <<<< ($_.status -eq "running")
+ CategoryInfo : InvalidArgument: (:) [Where-Object], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.WhereObjectCommand
Run Code Online (Sandbox Code Playgroud)
尝试在参数周围使用 {} 而不是括号。
http://technet.microsoft.com/en-us/library/ee177028.aspx
请仔细注意语法。首先,where 子句包含在花括号中;此外,$_ 符号用于表示默认对象(即通过管道传输的对象)。
您需要使用 { 而不是 (
Get-Service | Where-Object {$_.status -eq "running"}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4568 次 |
| 最近记录: |