Add to Technorati Favorites
Welcome to ThePowerShellGuy.com Sign in | Join | Help

Scripting Games 2007 Advanced PowerShell Scores list

To check the Scores in The Scripting Games 2007, I made the following script for the Advanced PowerShell Division :

( I did see also a version with Internet Explorer, on the NG and on a Blog  )

 

[string]$url="http://www.microsoft.com/technet/scriptcenter/funzone/games/games07/psascores.mspx"
$wc = new-Object System.Net.WebClient
$nl = $wc.DownloadString("$url")

$r = [regex]'l">(.*?)</p'
$m = $r.Matches($nl)
$l = $m |% {$_.groups[1].value}

$list = @()
foreach ($i in 13..($l.count -1) ) {
  $Record = new-Object -typename System.Object
  $Record | add-Member -memberType noteProperty -name Name -Value $m[$i].groups[1].value
  [void] $foreach.MoveNext()
  $Record | add-Member -memberType noteProperty -name Country -Value $m[$foreach.current].groups[1].value
  1..10 |% {[void] $foreach.MoveNext();$Record | add-Member -memberType noteProperty -name "E$_" -Value $m[$foreach.current].groups[1].value}
  [void] $foreach.MoveNext();$Record | add-Member -memberType noteProperty -name "Total" -Value $m[$foreach.current].groups[1].value
  $list += $record
}
. {

  "`nTop Individual Scores: Windows PowerShell Advanced Division"

  $nl -match 'as of (.*)</h2>' | out-null
  "Standings of : $( $matches[1] )"

  $list | ft * -a

  "`nCountry's :"
  $list | group country
}

 

If you paste this Code into your console you get the following output, and can play with $list Yourself after that

 

PoSH> [string]$url="http://www.microsoft.com/technet/scriptcenter/funzone/games/games07/psascores.mspx"                 
                                                                                                       
                                                                                                                        
                                                                                                                        
Top Individual Scores: Windows PowerShell Advanced Division                                                             
Standings of : February 19, 2007                                                                                        
                                                                                                                        
Name                       Country         E1 E2 E3 E4 E5 E6 E7 E8 E9 E10 Total                                         
----                       -------         -- -- -- -- -- -- -- -- -- --- -----                                         
/\/\o\/\/                  The Netherlands 10 5  10 5  5  10 10 -  5  -   60                                            
Frank Fattizzi             USA             10 5  10 5  5  10 -  -  5  -   50                                            
Jacob Gable                USA             10 5  10 5  5  10 -  -  5  -   50                                            
Jason Clement              USA             10 5  10 5  5  10 -  -  5  -   50                                            
Joseph Tilley              USA             10 5  10 5  5  10 -  -  5  -   50                                            
Marco Shaw                 Canada          10 5  10 5  5  10 -  -  5  -   50                                            
Mark Sheppard              United Kingdom  10 5  10 5  5  10 -  -  5  -   50                                            
Richard Siddaway           England         10 5  10 5  5  10 -  -  5  -   50                                            
Aaron Peterson             USA             10 5  10 5  5  10 -  -  -  -   45                                            
DS316                      Scotland        10 5  10 5  5  10 -  -  -  -   45                                            
Gilles LAURENT             France          10 5  10 5  5  10 -  -  -  -   45                                            
Jakub Niedzwiedz           Poland          10 5  10 5  5  10 -  -  -  -   45                                            
Jeremy Clore               USA             10 5  10 5  5  10 -  -  -  -   45                                            
Jason Joy                  USA             10 5  10 5  5  10 -  -  -  -   45                                            
Russ Pitcher               England         10 5  10 5  5  10 -  -  -  -   45                                            
MCNEILLWARE                USA             10 5  10 5  5  10 -  -  -  -   45                                            
Simon Dalling              England         10 5  10 5  5  10 -  -  -  -   45                                            
Yves PASCAULT              France          10 5  10 5  5  10 -  -  -  -   45                                            
Alex Duckworth             Australia       10 5  10 5  -  10 -  -  -  -   40                                            
Alex Chan                  USA             10 5  0  5  5  10 -  -  5  -   40                                            
Andy Schneider             USA             10 5  -  5  5  10 -  -  5  -   40                                            
Chi Chi                    USA             10 5  10 5  -  10 -  -  -  -   40                                            
Joel Bombardier            Switzerland     10 5  0  5  5  10 -  -  5  -   40                                            
Mike Holden                Albania         10 5  10 10 5  -  -  -  -  -   40                                            
Raja Mohamad Fairuz        Malaysia        10 5  10 5  0  10 -  -  -  -   40                                            
Sanket Shetye              India           10 5  10 5  -  10 -  -  -  -   40                                            
Shay Levy                  Israel          10 5  10 5  0  10 -  -  -  -   40                                            
Sander Rijken              The Netherlands 10 5  10 0  5  10 -  -  -  -   40                                            
Wrighty                    United Kingdom  10 5  10 5  5  -  -  -  -  -   35                                            
Arnaud PETITJEAN           France          10 5  10 5  -  -  -  -  -  -   30                                            
Arizona Claude Edwards     Jamaica         10 5  10 5  -  -  -  -  -  -   30                                            
David Saxon                United Kingdom  10 5  10 5  -  -  -  -  -  -   30                                            
Jean - JMST                Belgium         10 5  10 5  -  -  -  -  -  -   30                                            
Frodekommode               Norway          10 5  10 5  -  -  -  -  -  -   30                                            
Gaurhoth                   USA             10 5  10 5  -  -  -  -  -  -   30                                            
SUF                        Hungary         10 5  10 5  -  -  -  -  -  -   30                                            
Hugo Crossley              Malawi          10 5  10 5  -  -  -  -  -  -   30                                            
Nagy János                 Hungary         10 5  10 5  -  -  -  -  -  -   30                                            
Joe Topjian                USA             10 5  10 5  -  -  -  -  -  -   30                                            
Jerzy Prusinski            Poland          10 5  10 5  -  -  -  -  -  -   30                                            
Kasey Nichols              USA             10 5  10 5  -  -  -  -  -  -   30                                            
Michael Dickey             USA             10 5  10 5  -  -  -  -  -  -   30                                            
Peggy Peng                 PRC             10 5  10 5  -  -  -  -  -  -   30                                            
Rhoderick Milne            United Kingdom  10 5  10 5  -  -  -  -  -  -   30                                            
Reinhard Lehrbaum          Austria         10 5  10 5  -  -  -  -  -  -   30                                            
Robin LEMESLE              France          10 5  10 5  -  -  -  -  -  -   30                                            
Panderon                   Egypt           10 5  10 5  -  -  -  -  -  -   30                                            
Stefan Suesser             Germany         10 5  10 5  -  -  -  -  -  -   30                                            
Steve Kulyk                Canada          10 5  10 5  -  -  -  -  -  -   30                                            
Thorbjörn Sjövold          Sweden          10 5  10 5  -  -  -  -  -  -   30                                            
Tobias Reinwald            Germany         10 5  10 5  -  -  -  -  -  -   30                                            
Tom Glowacki               USA             10 5  10 5  -  -  -  -  -  -   30                                            
Stephen Correia - tumtum73 USA             10 5  10 5  -  -  -  -  -  -   30                                            
Umesh Chandra Thakur       India           10 5  10 5  -  -  -  -  -  -   30                                            
Keun Hyung, Lee            South Korea     10 5  10 5  -  -  -  -  -  -   30                                            
Antony Smoothey            England         10 5  10 -  -  -  -  -  -  -   25                                            
Alistair Young             USA             10 5  0  5  0  0  -  -  -  -   20                                            
Chris H (C2)               USA             0  5  10 5  -  -  -  -  -  -   20                                            
Vasily Gusev               Russia          -  -  -  5  5  10 -  -  -  -   20                                            
Huub van der Klooster      The Netherlands 10 5  0  5  -  -  -  -  -  -   20                                            
Kunio Hodozuka             Japan           10 5  -  5  -  -  -  -  -  -   20                                            
Micra                      Poland          -  5  10 5  -  -  -  -  -  -   20                                            
Necip TOMURCUK             Turkey          10 5  -  5  -  -  -  -  -  -   20                                            
Paul M Marshall            Australia       10 5  0  5  -  -  -  -  -  -   20                                            
Vinicius Canto             Brazil          10 5  -  5  -  -  -  -  -  -   20                                            
Xavier Courchinoux         France          10 -  10 -  -  -  -  -  -  -   20                                            
David M. Williams          Australia       10 5  -  -  -  -  -  -  -  -   15                                            
Andrei Fevralev            USA             -  -  10 5  -  -  -  -  -  -   15                                            
Rob van der Woude          The Netherlands -  -  10 5  -  -  -  -  -  -   15                                            
Captain Literal            United Kingdom  10 0  -  5  -  -  -  -  -  -   15                                            
Pake73                     Sweden          -  -  10 5  -  -  -  -  -  -   15                                            
Pavol Popovic              USA             10 5  -  -  -  -  -  -  -  -   15                                            
Richard_h9                 Australia       -  -  10 5  -  -  -  -  -  -   15                                            
Anonymous                  Australia       -  -  10 5  -  -  -  -  -  -   15                                            
Sysadmin Stickler          USA             -  -  10 -  -  -  -  -  -  -   10                                            
TLH                        USA             -  5  -  5  -  -  -  -  -  -   10                                            
Fj++                       Belgium         -  -  0  5  5  -  -  -  -  -   10                                            
Christian Pfeiffer         Austria         -  5  -  -  -  -  -  -  -  -   5                                             
Kent Finkle                USA             -  5  -  -  -  -  -  -  -  -   5                                             
MartinH                    Sweden          -  -  -  5  -  -  -  -  -  -   5                                             
Rick Tatem                 USA             -  -  0  5  -  -  -  -  -  -   5                                             
Kevin Oie                  USA             -  0  -  -  -  -  -  -  -  -   0                                             
                                                                                                                        
                                                                                                                        
                                                                                                                        
                                                                                                                        
Country's :                                                                                                             
                                                                                                                        
Count Name            Group                                                                                             
----- ----            -----                                                                                             
    4 The Netherlands {/\/\o\/\/, Sander Rijken, Huub van der Klooster, Rob van der Woude}                              
   26 USA             {Frank Fattizzi, Jacob Gable, Jason Clement, Joseph Tilley...}                                    
    2 Canada          {Marco Shaw, Steve Kulyk}                                                                         
    5 United Kingdom  {Mark Sheppard, Wrighty, David Saxon, Rhoderick Milne...}                                         
    4 England         {Richard Siddaway, Russ Pitcher, Simon Dalling, Antony Smoothey}                                  
    1 Scotland        {DS316}                                                                                           
    5 France          {Gilles LAURENT, Yves PASCAULT, Arnaud PETITJEAN, Robin LEMESLE...}                               
    3 Poland          {Jakub Niedzwiedz, Jerzy Prusinski, Micra}                                                        
    5 Australia       {Alex Duckworth, Paul M Marshall, David M. Williams, Richard_h9...}                               
    1 Switzerland     {Joel Bombardier}                                                                                 
    1 Albania         {Mike Holden}                                                                                     
    1 Malaysia        {Raja Mohamad Fairuz}                                                                             
    2 India           {Sanket Shetye, Umesh Chandra Thakur}                                                             
    1 Israel          {Shay Levy}                                                                                       
    1 Jamaica         {Arizona Claude Edwards}                                                                          
    2 Belgium         {Jean - JMST, Fj++}                                                                               
    1 Norway          {Frodekommode}                                                                                    
    2 Hungary         {SUF, Nagy János}                                                                                 
    1 Malawi          {Hugo Crossley}                                                                                   
    1 PRC             {Peggy Peng}                                                                                      
    2 Austria         {Reinhard Lehrbaum, Christian Pfeiffer}                                                           
    1 Egypt           {Panderon}                                                                                        
    2 Germany         {Stefan Suesser, Tobias Reinwald}                                                                 
    3 Sweden          {Thorbjörn Sjövold, Pake73, MartinH}                                                              
    1 South Korea     {Keun Hyung, Lee}                                                                                 
    1 Russia          {Vasily Gusev}                                                                                    
    1 Japan           {Kunio Hodozuka}                                                                                  
    1 Turkey          {Necip TOMURCUK}                                                                                  
    1 Brazil          {Vinicius Canto}                                                                                  
                                                                                                                        
                                                                                                                        
PoSH> 

 

As I did this 2 times allready on my blog ( Hey PowerShell, how popular is this Baby Name ? )

this might look familiar, but also might handy to check if your score is updated  as I added a datecheck to see if it is updated  ;-)

 

Enjoy,

 

Greetings /\/\o\/\/

Published Monday, February 19, 2007 4:19 PM by admin

Comments

# re: Scripting Games 2007 Advanced PowerShell Scores list

Once you get to here:

"foreach ($i in 13..($l.count -1) ) {"

I'm wondering if you'd mind commenting what you're doing from there and why?

Thursday, February 22, 2007 2:02 PM by Marco Shaw

# re: Scripting Games 2007 Advanced PowerShell Scores list

Hiya Marco,

hope I understand the Question, as I'm not sure about exactly what part of it you have problems with

$l contains the list of matches found (all cells of the table )

the Foreach will loop trough them all

I start at match 13 as the first rows contain the headers

PoSH> $l[0..12]

<b>Name</b>

<b>Country</b>

<b>Event 1</b>

<b>Event 2</b>

<b>Event 3</b>

<b>Event 4</b>

<b>Event 5</b>

<b>Event 6</b>

<b>Event 7</b>

<b>Event 8</b>

<b>Event 9</b>

<b>Event 10</b>

<b>Total</b>

So at 13 I get the fist list of names and scores :

PoSH> $l[13..25]

Aaron Peterson

USA

10

5

10

5

5

10

10

-

5

20

80

PoSH> $l[26..28]

Alex Chan

USA

10

as I use :

[void] $foreach.MoveNext()

to go to the next value in the loop I do process 13 matches (one row )every loop

and add them as properties to a new object

also see this post for more information :

http://thepowershellguy.com/blogs/posh/archive/2007/02/13/hey-powershell-how-popular-is-this-baby-name.aspx

Greetings /\/\o\/\/

Thursday, February 22, 2007 5:45 PM by MoW

# re: Scripting Games 2007 Advanced PowerShell Scores list

OK, I'm starting to dig ya!  I'll still have to give it a bit more thought...  You were wanting to set everything up as an object, as opposed to just going with a recordset.

I'll check out your other posts, but I'm also wanting to use the listing for totals, averages, medians, and the like to maybe having it all as objects will help me get my calculations done quicker...

Thursday, February 22, 2007 7:45 PM by Marco Shaw

# re: Scripting Games 2007 Advanced PowerShell Scores list

Marco,

> maybe having it all as objects will help me get my calculations done quicker...

Yes, that's the reason I make a collection if objects of it so I can do things like this :

$list | group country

try also measure-object :

$list| Measure-Object -property total -Average

h.t.h.

Greetings /\/\o\/\/

Friday, February 23, 2007 7:06 AM by MoW

# re: Scripting Games 2007 Advanced PowerShell Scores list

I also wondered what this was doing:

$Record = new-Object -typename System.Object

Then you pipe "nothing" to add-member.  Thought about it, then realized, how can you use 'add-member' when you haven't even anything in the pipeline.

So, you create an object, even if empty, then use add-member to add objects to the pipeline.

Cool example of add-member!

Friday, February 23, 2007 8:34 AM by Marco Shaw

# re: Scripting Games 2007 Advanced PowerShell Scores list

This may not be the most appropriate usage of add-member when dealing with an Int:

"add-Member -memberType noteProperty"

If you try something like a pipe with "?{$_.Total -ge 99}", you may not get the expected/wanted results.

I haven't figured out what to add...  I tried this, but it didn't work:

"add-member -membertype noteproperty -name [...] -value [...] -secondvalue System.Int32"

I don't think I can use System.Int32 with noteproperty...

Wednesday, February 28, 2007 9:23 PM by Marco Shaw

# re: Scripting Games 2007 Advanced PowerShell Scores list

Sorry,

I do not see the problem here, works for me :

PoSH> $o = new-object object

PoSH> $o | Add-Member  NoteProperty int 1

PoSH> $o.int | gm

  TypeName: System.Int32

Greetings /\/\o\/\/

Thursday, March 01, 2007 7:23 AM by MoW

# re: Scripting Games 2007 Advanced PowerShell Scores list

Fixed...  Turns out I had decleared the values as a [string] *before* creating the objects.  I just had to redeclare them as an [int], and all is well.

Thursday, March 01, 2007 7:57 AM by Marco Shaw

# re: Scripting Games 2007 Advanced PowerShell Scores list

Great code, hopefully we can change the 7 to an 8 and away we go for the 2008 games. Good luck everyone, don't forget to mark the 15th of February 2008 in your calendar, see you on the Scoreboard this year too..

Friday, January 25, 2008 2:21 PM by Simon Dalling

# First Scripting Games 2008 scores available

The first Scripting Games 2008 scores are available If you want to access the scores from PowerShell

Sunday, February 17, 2008 7:07 PM by The PowerShell Guy
Anonymous comments are disabled