Discussion:
The pipeline is empty
(too old to reply)
Jason
2008-08-01 18:37:23 UTC
Permalink
Why can't I pipe this through the pipeline?

PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}

When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Marco Shaw [MVP]
2008-08-01 19:09:11 UTC
Permalink
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...

Works fine here: XP SP2 with v2 CTP2.

OS? Posh version?

Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Jason
2008-08-01 19:23:02 UTC
Permalink
PS version 1.0 release. Windows XP Corporate SP2.
I was trying to pipe it to a table format, so I could get, multiple values
to look better. Here's what I need:
foreach ($obj in $this) {if ($obj.Responding -eq "True") {$obj.Processname,
$obj.Responding}} | ft
Post by Marco Shaw [MVP]
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...
Works fine here: XP SP2 with v2 CTP2.
OS? Posh version?
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Justin Rich
2008-08-01 19:39:45 UTC
Permalink
gps | where {$_.responding -eq "true"} | ft -property processname,
responding

so, this should work.... but... it doesnt... perhaps Marco or Shay can
help...

when i do the above, it seems to return a valid set... but, if i replace the
true, with false, i get back the same data set... im not really helping
anything here, just asking more questions :)
Post by Jason
PS version 1.0 release. Windows XP Corporate SP2.
I was trying to pipe it to a table format, so I could get, multiple values
foreach ($obj in $this) {if ($obj.Responding -eq "True")
{$obj.Processname,
$obj.Responding}} | ft
Post by Marco Shaw [MVP]
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...
Works fine here: XP SP2 with v2 CTP2.
OS? Posh version?
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Jason
2008-08-01 19:54:05 UTC
Permalink
Thanks for the input. I did find that I can use Where-object to do what you
did. I'm just not clear on why I don't can't pipe out the output of the
earlier command. It's a matter of finding why a foreach command doesn't push
anything to my pipeline. I'm still new to this, so I may be missing
something obvious.
Post by Justin Rich
gps | where {$_.responding -eq "true"} | ft -property processname,
responding
so, this should work.... but... it doesnt... perhaps Marco or Shay can
help...
when i do the above, it seems to return a valid set... but, if i replace the
true, with false, i get back the same data set... im not really helping
anything here, just asking more questions :)
Post by Jason
PS version 1.0 release. Windows XP Corporate SP2.
I was trying to pipe it to a table format, so I could get, multiple values
foreach ($obj in $this) {if ($obj.Responding -eq "True")
{$obj.Processname,
$obj.Responding}} | ft
Post by Marco Shaw [MVP]
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...
Works fine here: XP SP2 with v2 CTP2.
OS? Posh version?
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
unknown
2008-08-01 23:26:03 UTC
Permalink
From PowerShell 1 on an XP Pro SP3 system, I have no trouble with your
original command. A couple of minor details that _shouldn't_ make a
difference, but can simplify things and improve matching:

(1) According to my system, the Responding property is boolean; check the
output of this:

Get-Process | Get-Member -MemberType Properties R*

That being the case, you might do better by comparing to $true than "true".

(2) I doubt you did anything in between that messed with the content of
$procs, but you can embed gps into your for loop if you wish, making certain
that it's fresh, like this:

foreach ($obj in gps) {if ($obj.Responding -eq $true){$obj.Processname}}

Just out of curiosity, try the above, then try your original command again
as well. I would almost think the problem is an issue with type coercion, if
I wasn't having it work fine as the string "true" on my test setup. Perhaps
this is something that was modified by the .NET 2 service pack? <== (wild
and highly improbable guess)
Post by Jason
Thanks for the input. I did find that I can use Where-object to do what you
did. I'm just not clear on why I don't can't pipe out the output of the
earlier command. It's a matter of finding why a foreach command doesn't push
anything to my pipeline. I'm still new to this, so I may be missing
something obvious.
Post by Justin Rich
gps | where {$_.responding -eq "true"} | ft -property processname,
responding
so, this should work.... but... it doesnt... perhaps Marco or Shay can
help...
when i do the above, it seems to return a valid set... but, if i replace the
true, with false, i get back the same data set... im not really helping
anything here, just asking more questions :)
Post by Jason
PS version 1.0 release. Windows XP Corporate SP2.
I was trying to pipe it to a table format, so I could get, multiple values
foreach ($obj in $this) {if ($obj.Responding -eq "True")
{$obj.Processname,
$obj.Responding}} | ft
Post by Marco Shaw [MVP]
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...
Works fine here: XP SP2 with v2 CTP2.
OS? Posh version?
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
Jason
2008-08-04 12:58:01 UTC
Permalink
PS C:\> foreach ($obj in $this) {if ($obj.Responding -eq $true)
{$obj.Processname, $obj.Responding} | ft
An empty pipe element is not permitted.
At line:1 char:94
+ foreach ($obj in $this) {if ($obj.Responding -eq $true) {$obj.Processname,
$obj.Responding} | <<<< ft


Thanks for your suggestions. Why do I always find simple problems that turn
into big ones? ;)

I think I'll just learn to use where-object instead.
Post by unknown
From PowerShell 1 on an XP Pro SP3 system, I have no trouble with your
original command. A couple of minor details that _shouldn't_ make a
(1) According to my system, the Responding property is boolean; check the
Get-Process | Get-Member -MemberType Properties R*
That being the case, you might do better by comparing to $true than "true".
(2) I doubt you did anything in between that messed with the content of
$procs, but you can embed gps into your for loop if you wish, making certain
foreach ($obj in gps) {if ($obj.Responding -eq $true){$obj.Processname}}
Just out of curiosity, try the above, then try your original command again
as well. I would almost think the problem is an issue with type coercion, if
I wasn't having it work fine as the string "true" on my test setup. Perhaps
this is something that was modified by the .NET 2 service pack? <== (wild
and highly improbable guess)
Post by Jason
Thanks for the input. I did find that I can use Where-object to do what you
did. I'm just not clear on why I don't can't pipe out the output of the
earlier command. It's a matter of finding why a foreach command doesn't push
anything to my pipeline. I'm still new to this, so I may be missing
something obvious.
Post by Justin Rich
gps | where {$_.responding -eq "true"} | ft -property processname,
responding
so, this should work.... but... it doesnt... perhaps Marco or Shay can
help...
when i do the above, it seems to return a valid set... but, if i replace the
true, with false, i get back the same data set... im not really helping
anything here, just asking more questions :)
Post by Jason
PS version 1.0 release. Windows XP Corporate SP2.
I was trying to pipe it to a table format, so I could get, multiple values
foreach ($obj in $this) {if ($obj.Responding -eq "True")
{$obj.Processname,
$obj.Responding}} | ft
Post by Marco Shaw [MVP]
Post by Jason
Why can't I pipe this through the pipeline?
PS C:\>$procs = gps
PS C:\>foreach ($obj in $procs) {if ($obj.Responding -eq "True")
{$obj.Processname}}
When I try to pipe it out, it tells me "An empty pipe element is not
permitted."
Odd...
Works fine here: XP SP2 with v2 CTP2.
OS? Posh version?
Marco
--
*Microsoft MVP - Windows Server - Admin Frameworks
https://mvp.support.microsoft.com/profile/Marco.Shaw
*PowerShell Co-Community Director - http://www.powershellcommunity.org
*Blog - http://marcoshaw.blogspot.com
unknown
2008-08-04 13:11:46 UTC
Permalink
Post by Jason
Thanks for your suggestions. Why do I always find simple problems that turn
into big ones? ;)
Because we work in IT. ;)

Kiron
2008-08-01 23:39:05 UTC
Permalink
Enclose the ForEach statement in a SubExpression '$(...)'. Since the Responding Proprerty returns a [boolean] you don't have to compare its value, as Alex already stated. To get all 'not' Responding simply negate the [boolean] with the -not operator or its alias '!'.

# if Responding is $true
$(foreach ($obj in gps) {if ($obj.Responding) {$obj.Processname}})|ft
# if Responding is $false
$(foreach ($obj in gps) {if (!$obj.Responding) {$obj.Processname}})|ft

# in the pipeline
# if Responding is $true
gps | ? {$_.responding} | % {$_.processName} | ft
# if Responding is $false
gps | ? {!$_.responding} | % {$_.pr
Loading...