Werbung: SecurityConsole.de verwaltet Ihre Computer mit Security Essentails aus der Cloud!
30 Tage kostenfrei testen und 20% Rabatt für Ihre Bestellung mit Promocode: WBF2685582
(Promocode gültig bis 31.12.2011)

Group:  English: General » microsoft.public.windows.powershell
Thread: Functions: Taking input from the Pipe

HTVi
TV Discussion Newsgroups

Functions: Taking input from the Pipe
Christian Schindler 12/29/2008 3:21:00 PM
I'm working a lot with Exchange 2007 and when I retrieve an object and format
it with FL I get back a list of properties - but also properties that I'm not
interested in(for example GUID, etc).

So I normaly use SELECT to exclude those properties. However, specifying the
properties ever and ever again is a bit boring...

My idea was to write a function to have the same select command available
all the time... here is the function:

function esl {
select * -ExcludeProperty
Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
}

Now my problem is that the function does NOTHING. It seems as if it doesn't
take input from the pipe. I tried with SELECT -InputObject $_ - with no
success...

Any help would be appreciated!

TIA
Christian

Re: Functions: Taking input from the Pipe
"Vadims Podans" <vpodans> 12/29/2008 3:54:47 PM
your function does not receive any objects from pipe. You should specify
that pipeline is the source:
function esl {
$input | select * -ExcludeProperty
Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
}

$input contains all objects that was received from pipeline.

--
WBR, Vadims Podans
PowerShell blog - www.sysadmins.lv

"Christian Schindler" <ChristianSchindler[ at ]discussions.microsoft.com>
rakstīja ziņojumā
"news:B4FE516D-ADC7-4007-97E1-A42834FA5B70[ at ]microsoft.com"...
[Quoted Text]
> I'm working a lot with Exchange 2007 and when I retrieve an object and
> format
> it with FL I get back a list of properties - but also properties that I'm
> not
> interested in(for example GUID, etc).
>
> So I normaly use SELECT to exclude those properties. However, specifying
> the
> properties ever and ever again is a bit boring...
>
> My idea was to write a function to have the same select command available
> all the time... here is the function:
>
> function esl {
> select * -ExcludeProperty
> Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
> }
>
> Now my problem is that the function does NOTHING. It seems as if it
> doesn't
> take input from the pipe. I tried with SELECT -InputObject $_ - with no
> success...
>
> Any help would be appreciated!
>
> TIA
> Christian
>
Re: Functions: Taking input from the Pipe
"Christian Schindler" <cnschindler[ at ]gmx.net> 12/29/2008 6:21:22 PM
Thank you Vadmis!

That was exactly what I was looking for!

--
Christian Schindler

"Vadims Podans" <vpodans> wrote in message
news:eNJOc3caJHA.5520[ at ]TK2MSFTNGP02.phx.gbl...
[Quoted Text]
> your function does not receive any objects from pipe. You should specify
> that pipeline is the source:
> function esl {
> $input | select * -ExcludeProperty
> Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
> }
>
> $input contains all objects that was received from pipeline.
>
> --
> WBR, Vadims Podans
> PowerShell blog - www.sysadmins.lv
>
> "Christian Schindler" <ChristianSchindler[ at ]discussions.microsoft.com>
> rakstÄ«ja ziÅ?ojumā
> "news:B4FE516D-ADC7-4007-97E1-A42834FA5B70[ at ]microsoft.com"...
>> I'm working a lot with Exchange 2007 and when I retrieve an object and
>> format
>> it with FL I get back a list of properties - but also properties that I'm
>> not
>> interested in(for example GUID, etc).
>>
>> So I normaly use SELECT to exclude those properties. However, specifying
>> the
>> properties ever and ever again is a bit boring...
>>
>> My idea was to write a function to have the same select command available
>> all the time... here is the function:
>>
>> function esl {
>> select * -ExcludeProperty
>> Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
>> }
>>
>> Now my problem is that the function does NOTHING. It seems as if it
>> doesn't
>> take input from the pipe. I tried with SELECT -InputObject $_ - with no
>> success...
>>
>> Any help would be appreciated!
>>
>> TIA
>> Christian
>>

Re: Functions: Taking input from the Pipe
Shay Levy [MVP] <no[ at ]addre.ss> 12/29/2008 10:11:35 PM
Hi Christian,


You can use a filter. A filter is basically a function with a process clause
(no need to specify process{...}). The current object is $_:


filter esl{
$_ | select * -ExcludeProperty Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVersion,DistinguishedName
}


Now you can pipe to it:


cmdlet | esl




---
Shay Levy
Windows PowerShell MVP
http://blogs.microsoft.co.il/blogs/ScriptFanatic
PowerShell Toolbar: http://tinyurl.com/PSToolbar



CS> I'm working a lot with Exchange 2007 and when I retrieve an object
CS> and format it with FL I get back a list of properties - but also
CS> properties that I'm not interested in(for example GUID, etc).
CS>
CS> So I normaly use SELECT to exclude those properties. However,
CS> specifying the properties ever and ever again is a bit boring...
CS>
CS> My idea was to write a function to have the same select command
CS> available all the time... here is the function:
CS>
CS> function esl {
CS> select * -ExcludeProperty
CS> Guid,ObjectCategory,ObjectClass,WhenChanged,WhenCreated,ExchangeVers
CS> ion,DistinguishedName
CS> }
CS> Now my problem is that the function does NOTHING. It seems as if it
CS> doesn't take input from the pipe. I tried with SELECT -InputObject
CS> $_ - with no success...
CS>
CS> Any help would be appreciated!
CS>
CS> TIA
CS> Christian

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net
Suche nach Orten, Städten, Postleitzahlen, Vorwahlen, Kfz-Kennzeichen