Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Any ideas what I did wrong here? I copied this script from a tutorial and get this error....

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
share|improve this question

2 Answers 2

up vote 4 down vote accepted

Try using {} instead of parentheses around your argument.

http://technet.microsoft.com/en-us/library/ee177028.aspx

Take careful note of the syntax. To begin, the where clause is enclosed within curly braces; in addition, the $_ notation is used to represent the default object (that is, the object being transferred across the pipeline).

share|improve this answer
    
Perfect Thanks Holo! –  Campo Jun 16 '10 at 16:01

You need to use { instead of (

Get-Service | Where-Object {$_.status -eq "running"}
share|improve this answer
    
Holocryptic beat you by a minute :(. Still gave You a plus 1. Thanks! –  Campo Jun 16 '10 at 16:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.