powershell - Where-Object works locally but not remotely -


i'm trying learn powershell. wrote small script monitor exchange servers. can't understand why line work on local machine without problem

get-wmiobject -class win32_volume -filter 'drivetype = 3' | where-object 'label' -ne "system reserved" | ft systemname, driveletter, label, @{label='freespacegb'; expression={"{0:n0}" -f ($_.freespace/1gb)}} 

but if put same code invoke-command error.

invoke-command -computername $server -credential $c -scriptblock {     get-wmiobject -class win32_volume -filter 'drivetype = 3' | where-object 'label' -ne "system reserved" | ft systemname, driveletter, label, @{label='freespacegb'; expression={"{0:n0}" -f ($_.freespace/1gb)}}     } 

cannot bind argument parameter 'filterscript' because null. + categoryinfo : invaliddata: (:) [where-object], parameterbindingvalidationexception + fullyqualifiederrorid : parameterargumentvalidationerrornullnotallowed,microsoft.powershell.commands.whereobject command

i tried can think of without luck. check gm , label exist... tip..?

looks endpoint you're connecting powershell 2.0, doesn't have simplified where-object syntax.

try where-object instead:

where-object {$_.label -ne "system reserved"}