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 - Powershell bug?

Reply
 
Old 04-28-2007   #1 (permalink)
Jade Lee


 
 

Powershell bug?

It seems like a bug to me.
> PS> 1..50001 | Out-Null # It's just ok
> PS> 1..50002 | Out-Null # hmm...
> Bad range expression; 50001 is larger than the maximum size of a range
> (=50000 elements).
> At line:1 char:4
> + 1..5 <<<< 0002| Out-Null

Is this a bug?


My System SpecsSystem Spec
Old 04-28-2007   #2 (permalink)
William Stacey [C# MVP]


 
 

Re: Powershell bug?

On second line your asking for 50001 elements, but the max size is 50000 elements. So looks right to me. I assume the 50000 element range is just an arbitrary max to prevent people from maxing mem too easy.

--
William Stacey [C# MVP]


"Jade Lee" <redjadeDOTleeATgmailDOTcom> wrote in message news:%23vTovsaiHHA.4520@TK2MSFTNGP02.phx.gbl...
It seems like a bug to me.

PS> 1..50001 | Out-Null # It's just ok
PS> 1..50002 | Out-Null # hmm...
Bad range expression; 50001 is larger than the maximum size of a range (=50000 elements).
At line:1 char:4
+ 1..5 <<<< 0002| Out-Null
Is this a bug?

My System SpecsSystem Spec
Old 04-28-2007   #3 (permalink)
mikes.net


 
 

Re: Powershell bug?

> On second line your asking for 50001 elements, but the max size is 50000 elements. So looks right to me. I assume the 50000 element range is just an arbitrary max to prevent people from maxing mem too easy.

I wonder why these values would be cached in the first place? Sounds
like a design bug. At least the error message is good.

An ugly way to get around this bug, though you probably already knew
this and it wasn't your point...

$(for ($i = 0; $i -lt 50002; $i++) { $i } ) | out-null

Mike

My System SpecsSystem Spec
Old 04-28-2007   #4 (permalink)
klumsy@xtra.co.nz


 
 

Re: Powershell bug?

the 50,000 is a limit set by MS.. if it were 32768, 65536, 4gb or
something i might understand, but it seems a little contrived to me.
however maybe they were scared that people would do things that would
just put too many items into the pipelien by mistake?, anyhow i can't
see any good reason for it

however the fact that

1..50001 doesn't error out is interesting, this looks like a typical
"one bug". thought at least its benign.

My System SpecsSystem Spec
Old 04-29-2007   #5 (permalink)
/\\/\\o\\/\\/ [MVP]


 
 

Re: Powershell bug?

PoSH> (0..5000).count
5001

<klumsy@xtra.co.nz> wrote in message
news:1177803048.479053.209440@n76g2000hsh.googlegroups.com...
> the 50,000 is a limit set by MS.. if it were 32768, 65536, 4gb or
> something i might understand, but it seems a little contrived to me.
> however maybe they were scared that people would do things that would
> just put too many items into the pipelien by mistake?, anyhow i can't
> see any good reason for it
>
> however the fact that
>
> 1..50001 doesn't error out is interesting, this looks like a typical
> "one bug". thought at least its benign.
>


My System SpecsSystem Spec
Old 04-29-2007   #6 (permalink)
Jade Lee


 
 

Re: Powershell bug?

Jade Lee ¾´ ±Û:
> It seems like a bug to me.
>> PS> 1..50001 | Out-Null # It's just ok
>> PS> 1..50002 | Out-Null # hmm...
>> Bad range expression; 50001 is larger than the maximum size of a
>> range (=50000 elements).
>> At line:1 char:4
>> + 1..5 <<<< 0002| Out-Null

> Is this a bug?

Thanks ^^*

range : 1 ~ 50000
The sum of elements : 50001
Is it a right?

The statements "(=50000 elements)" confused me just a little.


My System SpecsSystem Spec
Old 05-01-2007   #7 (permalink)
Doug


 
 

Re: Powershell bug?

I think it's a bit of stretch to call this a feature.
Ranges are constrained to 50,000.
"Jade Lee" <redjadeDOTleeATgmailDOTcom> wrote in message news:eqXl6NniHHA.4496@TK2MSFTNGP05.phx.gbl...
Jade Lee ¾´ ±Û:
It seems like a bug to me.

PS> 1..50001 | Out-Null # It's just ok
PS> 1..50002 | Out-Null # hmm...
Bad range expression; 50001 is larger than the maximum size of a range (=50000 elements).
At line:1 char:4
+ 1..5 <<<< 0002| Out-Null
Is this a bug?

Thanks ^^*

range : 1 ~ 50000
The sum of elements : 50001
Is it a right?

The statements "(=50000 elements)" confused me just a little.


My System SpecsSystem Spec
Old 05-01-2007   #8 (permalink)
klumsy@xtra.co.nz


 
 

Re: Powershell bug?

yep but we did it based on one

(1..5001).count
5000

also it doesn't matter one or o based, it errors our when its greater
than 50001 rather tha 50,000

i.e

5..50005

My System SpecsSystem Spec
Old 05-03-2007   #9 (permalink)
William Stacey [C# MVP]


 
 

Re: Powershell bug?

Not sure you want to allow 1..[int]::maxvalue either as people would be crashing themselfs. So you need to pick some max. As shown in the thread, there are othe ways around it if you really need that many. You could also create your own range function and put it in your profile.

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


"Doug" <doug.sluis@gmail.com> wrote in message news:u4qdnfAsG6XSJqvbnZ2dnUVZ_jOdnZ2d@comcast.com...
I think it's a bit of stretch to call this a feature.
Ranges are constrained to 50,000.
"Jade Lee" <redjadeDOTleeATgmailDOTcom> wrote in message news:eqXl6NniHHA.4496@TK2MSFTNGP05.phx.gbl...
Jade Lee ¾´ ±Û:
It seems like a bug to me.

PS> 1..50001 | Out-Null # It's just ok
PS> 1..50002 | Out-Null # hmm...
Bad range expression; 50001 is larger than the maximum size of a range (=50000 elements).
At line:1 char:4
+ 1..5 <<<< 0002| Out-Null
Is this a bug?

Thanks ^^*

range : 1 ~ 50000
The sum of elements : 50001
Is it a right?

The statements "(=50000 elements)" confused me just a little.


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Installing PowerShell dependent features on W2K8 with PowerShell CTP PowerShell
when run powershell script as windows service ,powershell fail PowerShell
Powershell Plus - Free for non commercial Use and Powershell Analyzer1.0 released PowerShell
Automatic PowerShell Error Parsing in PowerShell Analyzer and PowerShellPlus PowerShell
PowerShell Leaders Join Forces and offer a pre-release version of PowerShell for 50% off the retail value PowerShell


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