Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > PowerShell

Can I pass object along the pipeline to a ps1?

Closed Thread
 
Thread Tools Display Modes
Old 03-08-2007   #1 (permalink)
Marco Shaw
Guest


 

Can I pass object along the pipeline to a ps1?

Can I do something like this?

ps|some.ps1|stop-process

A workaround of sorts was to use something like this:

ps|some_filter|stop-process

some_filter was simply a filter declaration contained in a ps1 script that I
dot-sourced containing something like:

filter some_filter {$_.something}

Marco


Old 03-08-2007   #2 (permalink)
Keith Hill [MVP]
Guest


 

Re: Can I pass object along the pipeline to a ps1?

"Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message
news:OzLWE6eYHHA.4308@TK2MSFTNGP05.phx.gbl...
> Can I do something like this?
>
> ps|some.ps1|stop-process


Yep but either some.ps1 has to be in your path or you have to specify the
full path to some.ps1. If the some.ps1 is in the current location then you
can specify the path like so:

ps | .\some \ stop-process

--
Keith


Old 03-08-2007   #3 (permalink)
Marco Shaw
Guest


 

Re: Can I pass object along the pipeline to a ps1?

> ps | .\some \ stop-process

Tried that but it didn't seem to work. I'll have to try again later.

I must check if you call a filter like you do a function in scripts.

Like having some.ps1 be:
-----start
filter some_filter {$_.something}
.. some_filter
-----end

Marco


Old 03-08-2007   #4 (permalink)
William Stacey [C# MVP]
Guest


 

Re: Can I pass object along the pipeline to a ps1?

Script blocks, functions, and scripts are all kinda related this way and
allow begin, process, end such as

PS C:\TEMP> cat myfilter.ps1
begin
{
echo "begin"
}
process
{
if ( $_.Name -like "zu*" ) { $_ } # Just output the ones you want (i.e.
filter objects).
}
end
{
"end"
}


Output
----------------------------------
PS C:\TEMP> ps | .\myfilter
begin

Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
40 2 716 2208 25 0.42 3856 ZuneLauncher
302 10 20644 25416 90 42.48 2332 ZuneNss
end

--
William Stacey [C# MVP]
PCR concurrency library: www.codeplex.com/pcr
PSH Scripts Project www.codeplex.com/psobject


"Marco Shaw" <marcoDOTshaw_@_gmailDOTcom> wrote in message
news:%23EPlHBfYHHA.1240@TK2MSFTNGP04.phx.gbl...
|> ps | .\some \ stop-process
|
| Tried that but it didn't seem to work. I'll have to try again later.
|
| I must check if you call a filter like you do a function in scripts.
|
| Like having some.ps1 be:
| -----start
| filter some_filter {$_.something}
| . some_filter
| -----end
|
| Marco
|
|


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
object pipeline? Mike Blake-Knox PowerShell 10 09-08-2007 08:53 AM
How to pass object to XAML page Lorenzo Soncini Avalon 0 10-23-2006 12:05 PM
Select a random object from pipeline effectively =?Utf-8?B?Um9tYW4gS3V6bWlu?= PowerShell 1 09-21-2006 03:44 PM
WMI Object Win32_Product and Pipeline woes machone3720 PowerShell 3 08-29-2006 09:05 AM
Add full (to pipeline) multicasting to tee-object? Andrew Watt [MVP] PowerShell 2 07-12-2006 12:29 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50