Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - How can select -first X work, but not select -last X

Reply
 
Old 12-12-2006   #1 (permalink)
Marco Shaw


 
 

How can select -first X work, but not select -last X

PS C:\> $authors|select -first 10

$_.header.from
--------------
"microsoft news" <oevinny@hotmail.com>
"v-haos" <v-haos@hotmail.com>
"v-haos" <v-haos@hotmail.com>
mk display name
mk display name
"Community User" <oe1@test.com>
"bvt2" <bvt2@oeexchange.com>
"msnews.microsoft.com" <someone at si-intl.com>
PS C:\> $authors|select -last 10
out-lineoutput : Object of type
"Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not legal
or not in
the correct sequence. This is likely caused by a user-specified "format-*"
command which is conflicting with the defaul
t formatting.

I don't get it. Can anyone explain?

Marco



My System SpecsSystem Spec
Old 12-12-2006   #2 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How can select -first X work, but not select -last X

It works for me with simple arrays and sequences, even if the count is lower
than the argument of -Last.

Do you see anything suspect if you do this:
$authors | get-member
And what object types are the members of $author?

"Marco Shaw" <marco@Znbnet.nb.ca> wrote in message
news:u7jAwriHHHA.3616@TK2MSFTNGP06.phx.gbl...
> PS C:\> $authors|select -first 10
>
> $_.header.from
> --------------
> "microsoft news" <oevinny@hotmail.com>
> "v-haos" <v-haos@hotmail.com>
> "v-haos" <v-haos@hotmail.com>
> mk display name
> mk display name
> "Community User" <oe1@test.com>
> "bvt2" <bvt2@oeexchange.com>
> "msnews.microsoft.com" <someone at si-intl.com>
> PS C:\> $authors|select -last 10
> out-lineoutput : Object of type
> "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not
> legal or not in
> the correct sequence. This is likely caused by a user-specified "format-*"
> command which is conflicting with the defaul
> t formatting.
>
> I don't get it. Can anyone explain?
>
> Marco
>



My System SpecsSystem Spec
Old 12-12-2006   #3 (permalink)
Marcel J. Ortiz [MSFT]


 
 

Re: How can select -first X work, but not select -last X

Any chance you could post where you're getting $authors from? (If it isn't
that large that is.) It would make it easier to try to repro.


"Marco Shaw" <marco@Znbnet.nb.ca> wrote in message
news:u7jAwriHHHA.3616@TK2MSFTNGP06.phx.gbl...
> PS C:\> $authors|select -first 10
>
> $_.header.from
> --------------
> "microsoft news" <oevinny@hotmail.com>
> "v-haos" <v-haos@hotmail.com>
> "v-haos" <v-haos@hotmail.com>
> mk display name
> mk display name
> "Community User" <oe1@test.com>
> "bvt2" <bvt2@oeexchange.com>
> "msnews.microsoft.com" <someone at si-intl.com>
> PS C:\> $authors|select -last 10
> out-lineoutput : Object of type
> "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not
> legal or not in
> the correct sequence. This is likely caused by a user-specified "format-*"
> command which is conflicting with the defaul
> t formatting.
>
> I don't get it. Can anyone explain?
>
> Marco
>



My System SpecsSystem Spec
Old 12-12-2006   #4 (permalink)
Lee Holmes [MSFT]


 
 

Re: How can select -first X work, but not select -last X

I suspect that $authors was created by:

$authors = $somethinghuge | ft @{ e= { $_.headers.from } }

In that case, $authors actually stores the output of the formatting, not the
objects themselves. If you send formatting records to the host in the wrong
order (such as the table end before the table beginning,) you get the error
you saw.

If you want to filter some properties, you would do:

$authors = $somethinghuge | select { $_.headers.from }

Although that generates a bunch of objects with just a "$_.headers.from"
property. If you want just the authors themselves, you might do:

$authors = $somethinghuge | foreach { $_.headers.from }

However, you might question why you are dropping the data -- the information
you need might be available without having to go through the middle step of
filtering.

--
Lee Holmes [MSFT]
Windows PowerShell Development
Microsoft Corporation
This posting is provided "AS IS" with no warranties, and confers no rights.



"Marcel J. Ortiz [MSFT]" <mosoto@online.microsoft.com> wrote in message
news:umGBarjHHHA.1248@TK2MSFTNGP03.phx.gbl...
> Any chance you could post where you're getting $authors from? (If it
> isn't that large that is.) It would make it easier to try to repro.
>
>
> "Marco Shaw" <marco@Znbnet.nb.ca> wrote in message
> news:u7jAwriHHHA.3616@TK2MSFTNGP06.phx.gbl...
>> PS C:\> $authors|select -first 10
>>
>> $_.header.from
>> --------------
>> "microsoft news" <oevinny@hotmail.com>
>> "v-haos" <v-haos@hotmail.com>
>> "v-haos" <v-haos@hotmail.com>
>> mk display name
>> mk display name
>> "Community User" <oe1@test.com>
>> "bvt2" <bvt2@oeexchange.com>
>> "msnews.microsoft.com" <someone at si-intl.com>
>> PS C:\> $authors|select -last 10
>> out-lineoutput : Object of type
>> "Microsoft.PowerShell.Commands.Internal.Format.FormatEntryData" is not
>> legal or not in
>> the correct sequence. This is likely caused by a user-specified
>> "format-*" command which is conflicting with the defaul
>> t formatting.
>>
>> I don't get it. Can anyone explain?
>>
>> Marco
>>

>
>



My System SpecsSystem Spec
Old 12-12-2006   #5 (permalink)
Marco Shaw


 
 

Re: How can select -first X work, but not select -last X

> Do you see anything suspect if you do this:
> $authors | get-member
> And what object types are the members of $author?


|gm was ugly...

$authors contains some ugly stuff in the last lines which was likely the
issue...

<bvt2@oeexchange.com>
à,?à,"à,µä,-æ-?
<v-haos1@hotmail.com>
à,?à,"à,µä,-æ-?
"Claus A. Munch" <munchen@disturbed.dk>
need.help.please@aol.com
?$B%K%e!<%9?(B
"asd" <asdfads@ad>
<v-xichen@oeexchange.com>
"D@ny" <dany484-news*STOP-SPAM*@yahoo.it>
<v-haos1@hotmail.com>
<zl991619@hotmail.com>
<prcmc07@hotmail.com>
<prcmc07@hotmail.com>


My System SpecsSystem Spec
Old 12-13-2006   #6 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How can select -first X work, but not select -last X

OK, how are you generating this? Share.

"Marco Shaw" <marco@Znbnet.nb.ca> wrote in message
news:eV95vQlHHHA.1008@TK2MSFTNGP06.phx.gbl...
>> Do you see anything suspect if you do this:
>> $authors | get-member
>> And what object types are the members of $author?

>
> |gm was ugly...
>
> $authors contains some ugly stuff in the last lines which was likely the
> issue...
>
> <bvt2@oeexchange.com>
> à,?à,"à,µä,-æ-?
> <v-haos1@hotmail.com>
> à,?à,"à,µä,-æ-?
> "Claus A. Munch" <munchen@disturbed.dk>
> need.help.please@aol.com
> ?$B%K%e!<%9?(B
> "asd" <asdfads@ad>
> <v-xichen@oeexchange.com>
> "D@ny" <dany484-news*STOP-SPAM*@yahoo.it>
> <v-haos1@hotmail.com>
> <zl991619@hotmail.com>
> <prcmc07@hotmail.com>
> <prcmc07@hotmail.com>
>



My System SpecsSystem Spec
Old 12-13-2006   #7 (permalink)
Marco Shaw


 
 

Re: How can select -first X work, but not select -last X

"Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message
news:%23Cwd5crHHHA.4216@TK2MSFTNGP06.phx.gbl...
> OK, how are you generating this? Share.


See thread "Loading 3rd party .NET assembly" from Dec 8th. You'll have to
install the Smilla NNTP .NET libray.

If you're willing to do that, I can provide my code that gets you to the
point where I was at.

Marco


My System SpecsSystem Spec
Old 12-14-2006   #8 (permalink)
Alex K. Angelopoulos [MVP]


 
 

Re: How can select -first X work, but not select -last X

got it, playing with it a bit, but it obviously takes learning some things
to work out my own code. Examples would be wonderful.

"Marco Shaw" <marco@Znbnet.nb.ca> wrote in message
news:uI0%23RDsHHHA.4896@TK2MSFTNGP04.phx.gbl...
> "Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message
> news:%23Cwd5crHHHA.4216@TK2MSFTNGP06.phx.gbl...
>> OK, how are you generating this? Share.

>
> See thread "Loading 3rd party .NET assembly" from Dec 8th. You'll have to
> install the Smilla NNTP .NET libray.
>
> If you're willing to do that, I can provide my code that gets you to the
> point where I was at.
>
> Marco
>



My System SpecsSystem Spec
Old 12-14-2006   #9 (permalink)
Marco Shaw


 
 

Re: How can select -first X work, but not select -last X


"Alex K. Angelopoulos [MVP]" <aka@online.mvps.org> wrote in message
news:Ooxkqs4HHHA.4688@TK2MSFTNGP04.phx.gbl...
> got it, playing with it a bit, but it obviously takes learning some things
> to work out my own code. Examples would be wonderful.


>>
>> See thread "Loading 3rd party .NET assembly" from Dec 8th. You'll have
>> to install the Smilla NNTP .NET libray.


If you mean examples to get and post, check out the thread where Jacques
provides a transcript. (Seems Google news/deja.com won't show his
article?!).

Also: http://www.smilla.ru/tutorial.html

Quickly:
$session = new-object smilla.net.nntpclient.session("news.microsoft.com")
$group=$session.getnewsgroup("microsoft.public.nntp.test")
$articles=$group.getarticles($true)
$authors=$articles.getarticlelist()|%{$_.header.from}

Hmm.... I think that was the group I queried... a '$authors|select -last
100' doesn't seem to err out anymore.

I dunno...


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
select case does not work ... why? VB Script
Select Files - Disable or Enable Full Row Select Tutorials
Select Certificate message, but no certificate to select Vista security
Select Certificate - but nothing to select Vista General
Multiple File Select and Select All Vista file management


Vista Forums 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 Ltd

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