Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all 3333 articles
Browse latest View live

2012 Scripting Games Beginner Event 8: Is Computer Desktop or Laptop?

$
0
0

 2012 Scripting Games badge

Summary: In Beginner Event 8, you are required to determine if a computer is a desktop computer or a laptop computer.

 

About this event

Division

Beginner

Date of Event

4/11/2012 12:01 AM

Due Date

4/18/2012 12:01 AM 

Event scenario

You are the desktop manager at a midsized enterprise company. It is inventory time, and you need to get a count of the number of laptop computers and the number of desktop computers. You decide to write a Windows PowerShell script that will count the number of desktop computers and the number of laptop computers on the network. To permit auditing, your report should include the computer name, and whether or not it is a desktop or a laptop machine.

Design points

  • For the purposes of this scenario, your script only needs to write to the console.
  • Your script only needs to determine laptop or desktop from a hardware perspective. You do not need to determine the version of the operating system.
  • Your code only needs to run on a local computer.
  • If your code requires admin rights, you should detect if the code is running as an admin or as a standard user. If your code works without requiring admin rights, you do not need to make this check.
  • Extra points for writing a simple function that only returns a Boolean value.

2012 Scripting Games links

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 


Scripting Wife’s Hints for Beginner Event 7

$
0
0

Summary: The Scripting Wife details her experience creating a script for Beginner Event 7 in the 2012 Scripting Games.

I will tell you what...sometimes I wonder about that Script Monkey. Actually, it is more than just sometimes. I thought this event was just a wee bit too hard. My score will probably drop several notches. Right now I am in position 21 (not that it matters, because I am ineligible for anything), but it is kind of cool. What is more cool is that only 1.5 points separate #1 from #28. I know, however, after my entry for this event factors in, I will no longer be in position 21. Oh well.

So what was my problem? I could not figure out how to get hidden event logs. Getting enabled event logs that have more than 0 records is not too hard. I needed to create a compound Where clause and look for records that are enabled and that have more than 0 records. This type of Where clause is a little tricky, but I used it in an earlier event when we were looking for running services that could also stop. If you missed that, you may want to look at some other people's entries (who got good scores). You may also want to look at some of the judges blogs (I talked about them in 2012 Scripting Games Blog Roll) because I remember seeing a blog by Don Jones where he talked about doing a compound Where clause. He gave a great example.

After sorting it, I picked up the two properties I needed and formatted it as a table. By the way, you might want to look at the Weekend Scripter: Troubleshooting Windows Hey, Scripting Guy! blog. It gave me several things to think about as I worked on my solution.

I guess maybe it was not really too hard, I will see when I get my score.

I hope you are doing well in the 2012 Scripting Games. Oh, by the way, if you are going to be in Atlanta on Saturday April 14, 2012, the Scripting Guy and I will be at the SQL Saturday #111 at the Georgia State University in Alpharetta. Hope to see you there.

Happy scripting,

~Scripting Wife.

Randomly Drawn Prize Winners: 2012 Scripting Games Day 2

$
0
0

Thank you for entering the 2012 Scripting Games. A special thank you to our wonderful sponsors for making these prizes possible. Please be sure to visit the sponsors page for more information about these awesome companies. We will send the prize winners an email with the pertinent information about their prizes soon.

Zak Humphries

1 ebook from Manning (ARV $40.00)

Alexis Ragual

1  ebook from Manning (ARV $40.00)

Jan R.

1  ebook from Manning (ARV $40.00)

Stijn Callebaut

1  ebook from Manning (ARV $40.00)

Dan70402

1  ebook from Manning (ARV $40.00)

RJSN

1  ebook from O’Reilly Media (ARV $20.00)

Kieran Walsh

1  ebook from O’Reilly Media (ARV $20.00)

DamienCharbonnel

1  ebook from O’Reilly Media (ARV $20.00)

KSchulte

1  ebook from O’Reilly Media (ARV $20.00)

ICC_JDyer

1  ebook from O’Reilly Media (ARV $20.00)

 

NakiPS1

1 each Amazon Gift ecard from BeyondTrust (ARV $50.00)

 

_Emin_

1  Windows PowerShell 2.0:TFM ebook from SAPIEN Technologies (ARV $34.99)

 

EasyMac308

 

1 copy PowerShell Plus Professional Edition version 4.0 from Idera (ARV $199)


 2012 Scripting Games badge

First Beginner Leaderboard of the 2012 Scripting Games

$
0
0

This is the first Beginner leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Beginner Events

User Name

Total Points

Scripts Rated

Total Ratings

John

9.5

2

6

NGelotte

9.5

2

4

andre

9.17

2

5

Andy Mello

9

2

4

Joe Keohan

9

2

5

wschoier

8.83

2

5

Mike F Robbins

8.75

2

7

Sahal Omer

8.67

2

5

Darren Maspero

8.67

2

6

Peter Heydon

8.5

2

5

NSlearningPS

8.5

2

4

octavmarius

8.5

2

4

Dawn Villejoin

8.42

2

7

Charlie Jacobson

8.33

2

5

therceg

8.33

2

5

clbarnett

8.33

2

6

mark_@_li

8.33

2

5

Mathieu Boulard

8.17

2

5

Mouton

8.17

2

5

Chris Manning @pbchris

8.17

2

5

jarheadf23

8.17

2

5

ScriptingWife

8.08

2

7

Jeremy Cox

8

2

4

MOW

8

2

4

Hov Arve

8

2

6

Don Hunt

8

2

4

CraigJahnke

8

2

4

Lido Paglia

8

2

5

DWS

7.83

2

5

Dennis Jarjosa

7.83

2

5

qsilverx

7.73

2

8

ngebhar2

7.67

2

5

Andrew Dauncey

7.67

2

5

AmandaD

7.67

2

5

Adam Funck

7.67

2

5

JeffWouters

7.63

2

11

Niel Fletcher

7.5

2

4

Bastien B

7.5

2

5

Matt Vidrine

7.5

2

4

Aaron Bednar

7.5

2

5

Oleg Suchkov

7.5

2

5

JoeTea

7.5

2

5

Yves PASCAULT

7.5

2

4

Alexis Ragual

7.5

2

4

Jan R.

7.5

2

4

lvimeux

7.5

2

4

SLevenberg

7.5

2

4

rumart

7.5

2

4

SM Yeoh

7.5

2

4

Dexter Dhami

7.5

2

5

Elmerp

7.5

2

4

James White

7.33

2

6

ruskie

7.33

2

5

Mr_Motown

7.33

2

7

Srikanth

7.33

2

6

TechguyTJ

7.33

2

5

Erica Miles

7.33

2

5

vNiklas

7.25

2

6

Maciej

7.25

2

6

Shevek

7.17

2

5

Fabio Jr

7.17

2

5

Michael Moore

7.17

2

5

David OBrien

7.17

2

5

Chris-D

7

2

4

L4NM4N

7

2

4

honeybadger

7

2

4

Zak Humphries

7

2

6

Dave Maldonado

7

2

5

BradC

7

2

4

Daniel Dittenhafer

7

2

4

Thomas Farmer

7

2

4

Andy Bidlen

7

2

4

Jordan Davis

7

2

5

Tomek A.

7

2

6

Nathan Mayberry

7

2

4

arnold moreno

7

2

6

Jerame Caudill

7

2

4

Forrest Stanley

7

2

4

Steve Hall

7

2

4

Ken Wilson

7

2

6

Brian Sabatini

7

2

4

sfibich

6.83

2

5

Tim Muessig

6.83

2

5

HitchHeik

6.83

2

5

TaylorGibb

6.75

2

6

Michael Odermatt

6.75

2

6

ICC_mworthley

6.75

2

6

Andrey Zvyagin

6.67

2

5

ckrull

6.67

2

6

yellowscope

6.67

2

6

emekm

6.67

2

6

Norman Manoh

6.5

2

5

Luke Forder

6.5

2

5

MattTilford

6.5

2

4

real fastcomputer

6.5

2

4

catremor

6.5

2

5

Brian Bohanon

6.5

2

4

David Waderich

6.5

2

4

Eric Pankowski

6.5

2

5

Chris Seiter

6.5

2

4

Stephen Correia

6.5

2

4

Daniel Headley

6.5

2

4

Carl

6.42

2

7

Tony Rad

6.33

2

5

shiv

6.33

2

5

Scott Button

6.33

2

6

MarcoB78

6.33

2

5

NCoppersmith

6.33

2

5

Daniel Thompson

6.33

2

6

MikeHowden

6.17

2

5

Jon McCormick

6.17

2

5

Lotte

6.17

2

5

Dan

6.17

2

5

Andrew Morgan

6.17

2

5

Ifiok Moses

6

2

4

Nathan Lare

6

2

4

ICC_jruff

6

2

4

Megha Kuruvilla

6

2

5

James Berkenbile

6

2

5

James McNeil

6

2

5

Grzegorz Kulikowski

6

2

4

Sai Prasad Vaddepally

6

2

4

tyoung

6

2

4

Shawn Melton

6

2

4

Derrick Michelson

6

2

4

Jeff Schulman

6

2

4

Daniel Killian

6

2

4

Chris Keim

6

2

4

cemarsh06

6

2

4

Clancy Wendt

6

2

4

Tim Watson

6

2

7

Jeffrey Jacobs

6

2

4

Sander

5.83

2

5

Scott Alvarino

5.83

2

5

sebuko

5.75

2

6

Japke

5.67

2

6

Clayton Firth

5.67

2

6

Derek Schauland

5.67

2

5

Cliff Harrison

5.67

2

6

Eleftheria Theologou

5.67

2

7

GCaporale

5.67

2

6

BernhardG

5.5

2

4

The Awesome-Machine.NET

5.5

2

4

Werner

5.5

2

5

John Russell

5.5

2

4

Sidewinder

5.5

2

4

Name

5.5

2

6

AballahSonDis

5.5

2

4

Shawn bequette

5.5

2

4

Xander Solis

5.5

2

5

Arif Ali

5.5

2

5

Emil Eriksson

5.5

2

4

Nadeem Vance

5.5

2

4

nyoro2

5.5

2

4

Paul Hiles

5.5

2

4

266ff21a196fda47d8b035a115fdeb42

5.5

2

5

DrLe

5.33

2

5

Mark P

5.33

2

5

Riwe

5.33

2

6

Duffman

5.33

2

5

James Stallwood

5.33

2

6

Vinay Bhandari

5.33

2

5

TSCSG

5.17

2

5

Roy M

5.17

2

5

Andy Wyse

5.17

2

5

eklime

5.17

2

5

Kevin

5.17

2

5

Sigitas Grėbliūnas

5

1

2

blahcubed

5

1

2

Andrew Cameron

5

1

2

mrgif1

5

1

2

greeme

5

2

4

robert broyles

5

2

4

Chuck Lathrope

5

2

6

Tom Parker

5

2

4

Patrik Lindström

5

2

6

Jonny Earl Grey Lindbom

5

2

6

jbrek

5

2

4

Timm Brochhaus

5

2

5

something easier to read

5

2

4

eribaq

5

2

6

Joshua Taylor

5

2

6

John Grenfell

5

2

5

Pradeep Rawat

5

2

4

SdeDot

5

2

5

ICC_RichardEisenberger

5

2

6

u2tb

5

2

4

Satheesh

5

2

5

DaveyK

5

2

5

BTmuney

4.83

2

5

radek

4.83

2

5

MarkIsBack

4.83

2

5

W. Sterling

4.83

2

5

jaydee

4.83

2

5

aaron d

4.83

2

5

NakiPS1

4.75

2

7

Yuri Kutovoy

4.75

2

7

Marty

4.75

2

6

AnotherPoShBlog

4.75

2

6

Neil Clinch

4.67

1

3

acchong

4.67

1

3

Jhonny Yamaniha

4.67

2

6

mvanhorenbeeck

4.67

2

6

Scott Baker

4.67

2

5

John van Leeuwen

4.67

2

5

aalaminos

4.67

2

5

Will Nevis

4.67

2

5

BenJT

4.67

2

5

Trevor Watkins

4.67

2

6

Dominic Leonard

4.67

2

5

Mallika Gogulamudi

4.67

2

6

Matt McAllister

4.67

2

6

Clayton McKenzie

4.67

2

6

Marcin Pietras

4.5

1

2

Wouter Beens

4.5

2

5

Andreas Engkvist

4.5

2

4

Matt benton

4.5

2

4

Dave Baird

4.5

2

4

Anthony Rum

4.5

2

5

Jess Pomfret

4.5

2

4

Jason Omar

4.5

2

5

Apnea

4.5

2

4

Jeff Maes

4.5

2

4

Joel Cook

4.5

2

4

Vern Anderson

4.5

2

4

David Christian

4.5

2

4

Mckie

4.5

2

6

Tyson J. Hayes

4.5

2

4

Zia

4.5

2

4

Mike Lambert

4.5

2

5

BreakDown

4.42

2

7

Sudeep Bhaskar

4.33

1

3

Andrew Gardner

4.33

1

3

jones89

4.33

2

5

Julie Andreacola

4.33

2

5

TomKupka

4.33

2

6

Brian Wuchner

4.33

2

6

JeremyB

4.33

2

6

Daniel Bicho

4.33

2

5

Mooseade

4.25

2

6

Petter Edin

4.17

2

5

evidence

4

1

2

Max Schnell

4

1

2

Nisha Sridhar

4

1

2

Thiyagu

4

1

2

Mark Amann

4

1

2

Francisco osorio

4

1

3

Ryan Schlagel

4

1

2

Filip Rejch

4

1

2

Jason Schmidtlein

4

1

3

James B. Bizzell

4

1

2

Kieran Walsh

4

2

4

plindgren

4

2

6

Mads Hjort Larsen

4

2

4

Marcos Tsuda

4

2

5

Geathan

4

2

6

Kryten-68

4

2

6

ICC_KFoley

4

2

5

Timo Skupin

4

2

6

Matt_A_

4

2

5

Nate Shepard

4

2

4

Phill McSherry

4

2

5

Daniel Snowden

4

2

5

Tim Miller

4

2

5

Matt Swint

4

2

5

dluke001

4

2

5

mtb44

3.83

2

5

joeartz

3.67

1

3

Leon Nell

3.67

2

6

Shaun Watts

3.67

2

6

Gica

3.67

2

7

Francisco Puig Diaz

3.58

2

7

Claymonster

3.5

1

2

sgatepunk

3.5

1

2

Bob__Mule

3.5

1

4

Brendan Erofeev

3.5

1

4

Ryan Youngs

3.5

1

2

Bryan

3.5

1

2

Pavan Hotha

3.5

1

2

zacd

3.5

1

2

Jay Lockard

3.5

1

2

Tony Uren

3.5

2

4

Greg Combs

3.5

2

4

Robert B

3.5

2

4

Bret Ridenour

3.33

2

6

peter bishop

3.33

2

6

Brett Chandler

3

1

2

redi311

3

1

2

mitch baker

3

1

3

Tim Hetzel

3

1

2

member2712

3

1

2

Jasper van der Heijden

3

1

2

mand0

3

1

2

Jude Croyle

3

1

2

Ola Skjeldal

3

1

2

jeprus

3

1

3

ocongil

3

1

2

MonitorMan

3

1

2

Sneel

3

1

2

70f53217af68ac357dfc1a46739257a6

3

1

2

Jonathan Birkett

3

1

2

Chris Albert

3

1

2

iTodd

3

1

2

John OHarra

3

2

7

Chris Watson

3

2

4

Steve Mahoney

3

2

5

b4d93r

3

2

4

Jason Y.

3

2

4

Dominic Daigle

3

2

7

Rich Oswald

3

2

4

e46d8dd2e1625c7a6182b82bc012a7e0

2.83

2

5

Clinton Merritt

2.5

1

2

Dennis James

2.5

1

2

Jakob Bindslet

2.5

1

2

TheZmann

2.5

1

2

Tobias

2.5

1

2

Crystal Diaz

2.5

1

2

erunama

2.5

2

4

lamaar75

2.5

2

5

Shaun Gibbs

2.5

2

4

Dexter

2.5

2

4

Jeremy Dunlop

2.33

1

3

Coderaven

2.33

1

3

Jay mac

2.33

1

3

Vinay Thakur

2.33

2

5

toumi walid

2.33

2

6

Brian Fraley

2

1

3

a64c64bd8e1fe90b8b024ab272090e32

2

1

2

skynetx

2

1

2

Mod10

2

2

5

kloinerFeigling83

2

2

5

MrBatchFile

2

2

4

Stephen Brown

2

2

4

Luca Christmann

1.5

1

2

Byty

1.5

1

2

PSLearner

1.5

1

2

Sean Massey

1.33

1

3

le4ne

1.33

1

3

Marcin Kowalczyk

1.33

1

3

Josh Nylander

1

1

3

Daed

1

1

2

David Granlund

1

1

2

Anjan Chidurala

1

1

2

3166f9ba33499b4658123e7b0a84598f

1

1

2

Jeremy Kieler

1

1

2

WizardX

1

1

4

Chris Nakagaki (Zsoldier)

1

1

2

2e638c99ea54b4ddb208033083f4ef24

1

1

2

Gabriel Tapia

1

1

2

Anders Wang

1

1

2

TitleRequired

1

1

2

John Main

1

1

2

j.vogt

1

1

2

RJSN

1

1

2

DisplayName

1

1

2

Nico

1

1

3

Gary Jackson

1

1

3

Eric Ray

1

1

3

ResetSA

1

1

2

TechJLS3

1

1

4

Jason Shaw

1

1

3

gary gray

1

1

4

 

First Advanced Leaderboard of the 2012 Scripting Games

$
0
0

This is the first Advanced leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Advanced Events

User Name

Total Points

Scripts Rated

Total Ratings

Martijn Haverhoek

10

2

4

Albert Fortes

9.33

2

4

Rohn Edwards

9

2

3

Sergey Borisovich

9

2

5

Ryan C

9

2

4

SimonW

8.67

2

5

Jeremy Caauwe

8.5

2

5

KSchulte

8.5

2

4

Tim Parkinson

8.5

2

3

Michał Gajda

8.5

2

3

Glenn Faustino

8.42

2

7

Rob Campbell

8.33

2

5

EasyMac308

8.17

2

5

Aleksey Shuvalov

8.17

2

5

LaPhi

8

2

4

Matthew Painter

8

2

3

BigTeddy

8

2

5

Nathan Linley

8

2

5

Kevin Hopcroft

8

2

4

George Kesler

7.67

2

5

Jason Stangroome

7.67

2

6

gbdixg

7.67

2

5

Kiss Tamás

7.67

2

5

Jason Hofferle

7.5

2

3

Jesper Strandberg

7.5

2

3

Billy Angers

7.5

2

3

Peter Heydon

7.5

2

4

Łukasz Kałużny

7.5

2

4

Grégory LUCAND

7.5

2

4

Dan70402

7.5

2

3

Prosvetov Roman

7.5

2

4

sstranger

7.5

2

4

Mike Hammond

7.5

2

4

Jack Chang

7.33

2

6

Max Lindström

7

2

6

Brent Challis

7

2

3

Carlos Nunez

7

2

4

Tom Parker

7

2

4

_Emin_

7

2

4

marcadamcarter

7

2

3

Scott1138

7

2

3

John Sneddon

7

2

4

vNoob

7

2

7

Kyle Neier

7

2

3

Ed Withers

7

2

4

ScripterJT

7

2

4

Serkan Varoglu

6.67

2

5

PeetersOnlineNL

6.67

2

5

Frederick Duemig

6.5

2

3

Tomek Izydorczyk

6.5

2

4

Ryan Ries

6.5

2

4

Alex McFarland

6.5

2

3

Jeff Patton

6.5

2

5

Trevor Hayman

6.5

2

4

Brad Blaylock

6.5

2

4

Brian Wilhite

6.5

2

4

Robert Mongold

6.5

2

4

Patrik Lindström

6.17

2

5

Robert Eder

6

2

3

Ken Hamilton

6

2

7

Steven Hall

6

2

5

Vladimir Stepic

6

2

4

Michael Moore

6

2

4

Vincent Van Hecke

6

2

4

Paul Cunningham

5.67

2

4

Matthew Graeber

5.5

2

4

Paulo J

5.5

2

4

Calle E

5.33

2

5

aml

5.17

2

5

Jon Bryan

5.17

2

5

Dave Griffiths

5

1

2

Jason Scott

5

1

2

Mark Weaver

5

1

2

Yuri Kutovoy

5

2

5

Brian Carr

5

2

3

DamienCharbonnel

5

2

4

james seatter

5

2

5

ICC_RyanDennis

5

2

6

Cesar Mendoza

4.83

2

5

f2b95d1a805fd4f8623b0d70b6ed3a19

4.67

2

4

Wes Stahler

4.5

1

2

Ken

4.5

1

2

Tom_G

4.5

1

2

Brandon Bettle

4.5

2

3

Anthony Rum

4.5

2

4

Ayo Wu

4.5

2

4

ICC_JDyer

4.33

2

4

UGSING_MattHitchcock

4

1

3

Paul Iddon

4

1

2

Joe D.

4

1

2

Francis D

4

1

3

Thomas Paetzold

4

1

2

jillwi

4

1

3

Jason Cole

4

1

2

Anonimista

4

1

2

Jimmy Mac

4

1

1

Clinton Merritt

4

1

2

andre2

4

1

2

Claudiu P

4

1

2

Warpig

4

1

2

Justin Sowa

4

1

2

Cameron Ove

4

1

2

T-Bone

4

1

2

Tobias

4

1

2

Jose Quinones

4

1

2

smoshea

4

1

2

MOW

4

2

5

Fredrik Wall

4

2

6

Serg

4

2

5

Cameron Wilson

4

2

5

Dan Richardson

3.67

1

3

Mr grnnnx

3.67

1

3

Mikko

3.67

1

3

herschelle

3.67

1

3

jeffrey yao

3.67

1

3

Jaap Brasser

3.67

1

3

MSFTW

3.67

1

3

Steelwing

3.67

1

3

Jason Wood

3.67

1

3

Tony McGee

3.5

1

2

Clint Bergman

3.5

1

2

PeterCS

3.5

1

2

Chris Oswalt

3.5

1

2

Wolfgang Kais

3.5

1

2

Scott A. Alvarino

3.5

1

2

Yves P

3.5

1

2

Joel Reed @J_lR_d {AZPOSH}

3.5

1

2

Wayne Gault

3.5

1

2

Igway Jacobs

3.5

1

2

Ryan Schlagel

3.5

1

2

J Skiba

3.5

1

2

resolver101

3.5

1

2

Jason Lange

3.5

1

2

Brian Wuchner

3.5

1

2

John Main

3.5

1

2

Matthew BETTON

3.5

1

2

Matt Gohmann

3.5

1

2

Yuriy Prikhodko

3.5

1

2

Sergey Vorontsov

3.5

1

2

j.vogt

3.5

1

2

Greg Martin

3.5

1

2

IJuan

3.5

1

2

Claus Søgaard

3.5

1

2

d0b3a82ee5864d5c5535edf2820a844a

3.5

1

2

Joshua Fuente

3.5

1

2

Chris Stewart

3.5

1

2

BurntChimney

3.5

1

2

PatrikL

3.5

1

2

jessekozloski

3.5

1

2

Oneill Cameron

3.5

1

2

redi311

3.5

1

2

Ryan Shafer

3.5

1

2

MarkJohnson

3.5

1

2

Patrick Dorsch

3.5

1

2

ThoamsBiebl

3.5

1

2

Frank Peter Schultze

3.5

1

2

Sam

3.5

1

2

Miruu

3.5

1

2

Bob__Mule

3.33

1

3

Josh

3.33

1

3

ICC_RDurkin

3

1

1

Nuno Mota

3

1

1

Robert van den Nieuwendijk

3

1

2

Stephanevg

3

1

2

Chris Brown

3

1

2

Jacques

3

1

2

Mike Lambert

3

1

2

kiran reddy

3

1

3

Daniel Cruz

3

1

2

Franck RICHARD

3

1

2

Pete Maan

3

1

2

Kirk Cessac

3

1

2

DJ Grijalva

3

1

2

blindrood

3

1

3

David Eilers

3

1

2

Michael Topal

3

1

2

Dexter

3

1

2

crownedjitter

3

1

2

Stijn Callebaut

3

1

2

Jiri Formacek

3

1

2

MattBoren

3

1

1

Zach M

3

1

2

Jonny Earl Grey Lindbom

3

1

3

Jakob Bindslet

3

1

3

Kim Tram

3

1

2

ginno

3

1

2

Tom Moser

3

1

2

Greg Shay

3

1

2

JeremiahC

3

1

2

AaronHoover

3

1

1

Ken Lin

3

1

1

Matthew Vidrine

3

1

2

hemanth.damecharla

3

1

2

Pemo

3

1

2

ofirey

3

1

2

Erin Huligan

3

1

2

Frank Migacz

3

1

2

Scripting Scott Saari

3

1

2

Robert de Britto

3

1

2

Gregg Britton

3

1

2

MSFT-AutomationJason

2.5

1

2

James Tryand

2.5

1

2

Dan Lepine

2.5

1

2

dude9000

2.5

1

2

Sai Prasad Vaddepally

2.5

1

2

Sean Decker

2.5

1

2

Chris Duck

2.5

1

2

Claudio Westerik

2.5

1

2

Perry Harris

2.5

1

2

Eddy Steenbergen

2.5

1

2

AZPOSH - Brian T Young

2.5

1

2

Will Steele

2

1

4

Nathan Cook - AU

2

1

2

Dave Ackroyd @LearnPowerShell

2

1

4

Rich Kusak

2

1

1

Joshua Feierman

2

1

2

BobMule

2

1

2

Franck Malterre

2

1

2

Marcin Kowalczyk

2

1

2

Brentos

2

1

2

skynetx

2

1

2

845ebf71ea404155b02971a5b6e8bc8d

2

1

2

Jason Milczek

2

1

2

TechJLS3

2

1

1

WizardX2

2

1

2

Luca Christmann

1.67

1

3

Rob Dowell

1.5

1

2

El Ryan

1.5

1

2

mand0

1.5

1

2

Internal_IT

1.5

1

2

Filip Rejch

1.5

1

2

Daed

1.5

1

2

Damon Brinkley

1.5

1

2

Andrew

1.5

1

2

Jim Vierra

1.33

1

3

Justin Stokes

1

1

2

Brian T. Jackett

1

1

2

Ákos Kinczel

1

1

2

Johan Åkerström

1

1

2

Schlauge

1

1

3

Dustin Hedges

1

1

2

Hong

1

1

2

Sean Brown Houses

1

1

2

Ken King

1

1

1

Valeriy Aksyonov

1

1

2

19691edf5d765a567ae58fb19f113083

1

1

2

Jude Croyle

1

1

2

Chris Nakagaki (Zsoldier)

1

1

2

 

Scripting Games Server off line for scheduled maintenance

$
0
0
Summary: the service that hosts PoshCode will be off line on April 13 for about a half an hour. Here is the message from the service that hosts the PoshCode database that is running the 2012 Scripting Games: “This is an important message regarding your...(read more)

2012 Scripting Games Advanced Event 9: Perform an Inventory

$
0
0

 2012 Scripting Games badge

Summary: In Advanced Event 9, you are required to perform a hardware inventory and write the information to an XML file.

 

About this event

Division

Advanced

Date of Event

4/12/2012 12:01 AM

Due Date

4/19/2012 12:01 AM

Event scenario

You are a network manager at a medium-sized organization, and it is time to perform an inventory of computers on the network. You need to collect the following information: computer name, domain name, computer manufacturer, computer model, number of processors, number of cores, speed of processors, processor ID, MAC address of the primary network interface, operating system version (including service pack level), and the amount of physical memory that is installed (displayed in the most logical units). Your output should be stored in an XML-formatted file in the Documents special folder. The file name should be the Computername (including domain name) and the date in year, month, day format. 

Design points

There are several requirements for this scenario:

  • Obtaining the information.
    • Storing the output in XML format.
    • Creating the file in a specific location
    • Creating the file name in the specific fashion, for example:
      Mycomputer.mydomain.20120412.XML
  • Because the script will run locally on the computer, it does not need the ability to run against remote computers.
  • Extra points for adding error handling for missing properties

2012 Scripting Games links

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 

2012 Scripting Games Beginner Event 9: Search the Event Log

$
0
0

 2012 Scripting Games badge

Summary: In Beginner Event 9, you are required to search the event log for specific entries.

About this event

Division

Beginner

Date of Event

4/12/2012 12:01 AM

Due Date

4/19/2012 12:01 AM

Event scenario

You are trying to troubleshoot shutdown issues on your laptop. It appears to hang for few seconds before it begins the shutdown process. You were looking through the application event log, and you noticed an event log entry that states that the BTTray.exe application attempted to veto the shutdown (how rude). A sample event log entry is shown in the image that follows.

Image of event log

You decide to search the application log for other event log entries from this source to determine how often this particular application is attempting to veto the shutdown, and to see if there are other applications doing the same thing. You write a quick one-line Windows PowerShell command that displays the date of the occurrence and the application name. An acceptable output is shown in the image that follows (the column headings are hidden because part of the problem is finding the properties to display).

Image of command output

Design points

  • Your command should be as efficient as possible; therefore, you want to limit the entries that are returned from the event log to only those that match the particular scenario. For hints on the filter to use, study the event log entry (the first image).
  • Keep in mind that what appears in a graphical tool is not always what you need to use in your filter.
  • Be careful with the number of entries returned from the application log—make your filter as efficient as possible. You will lose points for inefficient queries.
  • Because you are troubleshooting your computer, this is not a long involved script, but a “one liner.” Do not get carried away writing a complex script—complexity will cost you points.

2012 Scripting Games links

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 


Randomly Drawn Prize Winners: 2012 Scripting Games Day 3

$
0
0

Thank you for entering the 2012 Scripting Games. A special thank you to our wonderful sponsors for making these prizes possible. Please be sure to visit the sponsors page for more information about these awesome companies. We will send the prize winners an email with the pertinent information about their prizes soon. 

James Stallwood

1  ebook from O’Reilly Media (ARV $20.00)

jaydee

1  ebook from O’Reilly Media (ARV $20.00)

Matt Gohmann

1  ebook from O’Reilly Media (ARV $20.00)

Sergey Vorontsov

1  ebook from O’Reilly Media (ARV $20.00)

Michael Topal

1  ebook from O’Reilly Media (ARV $20.00)

Jason Y.

1 ebook from Manning (ARV $40.00)

Andrew Dauncey

1  ebook from Manning (ARV $40.00)

Riwe

1  ebook from Manning (ARV $40.00)

Igway Jacobs

1  ebook from Manning (ARV $40.00)

Jason Wood

1  ebook from Manning (ARV $40.00)

Robert Mongold

1 each Amazon Gift ecard from BeyondTrust (ARV $50.00)

Matthew Graeber

1 copy PowerShell Video Training Set from SAPIEN Technologies (ARV $99)

Clinton Merritt

1 copy PowerShell Plus Professional Edition version 4.0 from Idera (ARV $199)

 

 2012 Scripting Games badge

Beginner Leaderboard of the 2012 Scripting Games: Day 2

$
0
0

This is the Beginner leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Beginner Events

User Name

Total Points

Scripts Rated

Total Ratings

andre

14.42

3

8

Mike F Robbins

14

3

9

wschoier

13.83

3

6

Chris Manning @pbchris

13.67

3

7

Sahal Omer

13.67

3

6

Mathieu Boulard

13.25

3

7

Don Hunt

13.17

3

6

Lido Paglia

13

3

6

Yves PASCAULT

12.83

3

6

mark_@_li

12.83

3

7

ruskie

12.75

3

7

James White

12.75

3

8

Adam Funck

12.75

3

7

AmandaD

12.75

3

7

Maciej

12.75

3

8

Oleg Suchkov

12.75

3

7

qsilverx

12.73

3

9

BradC

12.5

3

6

Dawn Villejoin

12.5

3

10

NGelotte

12.5

3

5

ngebhar2

12.5

3

7

SLevenberg

12.5

3

6

Brian Sabatini

12.5

3

7

rumart

12.5

3

6

David OBrien

12.5

3

7

Dexter Dhami

12.5

3

6

Mr_Motown

12.33

3

9

Andy Bidlen

12.33

3

6

Srikanth

12.33

3

7

Charlie Jacobson

12.33

3

6

Jordan Davis

12.25

3

8

Dave Maldonado

12.25

3

7

vNiklas

12.25

3

7

Mouton

12.25

3

7

arnold moreno

12.2

3

8

Jeremy Cox

12.17

3

6

Nathan Mayberry

12

3

5

Eric Pankowski

12

3

7

Stephen Correia

12

3

6

Zak Humphries

12

3

7

Andy Mello

12

3

5

MattTilford

11.83

3

6

Tim Muessig

11.83

3

8

NSlearningPS

11.83

3

6

Andrew Morgan

11.75

3

7

ScriptingWife

11.75

3

10

Luke Forder

11.75

3

7

yellowscope

11.75

3

8

Brian Bohanon

11.67

3

7

Ifiok Moses

11.67

3

6

ICC_jruff

11.67

3

6

JeffWouters

11.63

3

13

Michael Moore

11.5

3

7

Chris Seiter

11.5

3

5

Matt Vidrine

11.5

3

6

JoeTea

11.5

3

6

Shawn Melton

11.5

3

6

Chris-D

11.5

3

6

Carl

11.42

3

9

Nathan Lare

11.33

3

6

James Berkenbile

11.33

3

7

tyoung

11.33

3

6

clbarnett

11.33

3

8

therceg

11.33

3

6

Dan

11.33

3

7

jarheadf23

11.25

3

7

Ken Wilson

11.25

3

8

Shevek

11.17

3

6

Cliff Harrison

11.17

3

8

Derek Schauland

11

3

7

Bastien B

11

3

8

CraigJahnke

11

3

5

Grzegorz Kulikowski

11

3

5

emekm

11

3

8

Daniel Thompson

10.83

3

8

David Waderich

10.83

3

6

Duffman

10.75

3

8

MikeHowden

10.75

3

7

Andrew Dauncey

10.67

3

6

James McNeil

10.67

3

8

DrLe

10.67

3

7

TechguyTJ

10.67

3

7

Eleftheria Theologou

10.67

3

8

honeybadger

10.5

3

6

Aaron Bednar

10.5

3

7

Werner

10.5

3

8

SM Yeoh

10.5

3

5

Nadeem Vance

10.5

3

5

nyoro2

10.5

3

5

Jon McCormick

10.5

3

8

Elmerp

10.5

3

5

Erica Miles

10.5

3

7

James Stallwood

10.42

3

8

Chris Keim

10.33

3

6

NCoppersmith

10.33

3

6

jaydee

10.33

3

7

Marty

10.25

3

8

BTmuney

10.25

3

8

Tim Watson

10.2

3

9

Daniel Dittenhafer

10.17

3

7

John Russell

10.17

3

6

Fabio Jr

10.17

3

6

BernhardG

10.17

3

6

Paul Hiles

10.17

3

6

Jhonny Yamaniha

10.08

3

8

blahcubed

10

2

3

mrgif1

10

2

3

Joshua Taylor

10

3

9

SdeDot

10

3

6

Joe Keohan

10

3

7

L4NM4N

10

3

6

Mark P

10

3

8

Xander Solis

10

3

8

AballahSonDis

10

3

6

Clancy Wendt

10

3

6

Sidewinder

10

3

6

Will Nevis

10

3

8

Patrik Lindström

10

3

7

Matt benton

9.83

3

6

Scott Alvarino

9.83

3

6

Clayton McKenzie

9.75

3

8

GCaporale

9.75

3

9

ICC_mworthley

9.75

3

9

Julie Andreacola

9.75

3

7

eklime

9.75

3

8

Neil Clinch

9.67

2

4

Vinay Bhandari

9.67

3

7

Pradeep Rawat

9.67

3

8

real fastcomputer

9.67

3

6

John

9.6

2

7

ckrull

9.58

3

9

JeremyB

9.58

3

9

Marcin Pietras

9.5

2

4

Sigitas Grėbliūnas

9.5

2

4

Tony Rad

9.5

3

8

Megha Kuruvilla

9.5

3

7

Daniel Headley

9.5

3

5

Derrick Michelson

9.5

3

6

Andreas Engkvist

9.5

3

7

aalaminos

9.5

3

8

Norman Manoh

9.5

3

6

MarkIsBack

9.33

3

7

Daniel Killian

9.33

3

7

Mooseade

9.25

3

8

John Grenfell

9.25

3

7

Mads Hjort Larsen

9.17

3

7

Trevor Watkins

9.08

3

8

Gica

9.07

3

9

Thiyagu

9

2

3

Hov Arve

9

3

7

Daniel Bicho

9

3

7

shiv

9

3

7

DaveyK

9

3

9

Tyson J. Hayes

9

3

6

catremor

9

3

7

AnotherPoShBlog

8.9

3

8

Darren Maspero

8.83

2

7

Zia

8.83

3

7

aaron d

8.83

3

6

Peter Heydon

8.75

2

6

Wouter Beens

8.75

3

7

Jason Omar

8.75

3

8

Scott Baker

8.75

3

7

David Christian

8.67

3

6

mvanhorenbeeck

8.67

3

8

BreakDown

8.67

3

9

Roy M

8.67

3

7

Sai Prasad Vaddepally

8.67

3

6

Chuck Lathrope

8.67

3

8

octavmarius

8.5

2

5

Timo Skupin

8.5

3

9

jbrek

8.5

3

6

Lotte

8.5

3

7

John OHarra

8.4

3

9

Rich Oswald

8.33

3

6

mtb44

8.33

3

8

Riwe

8.33

3

7

The Awesome-Machine.NET

8.33

3

6

Phill McSherry

8.33

3

7

Jason Y.

8.33

3

7

Dominic Leonard

8.33

3

7

Dennis Jarjosa

8.25

2

6

Yuri Kutovoy

8.25

3

9

lvimeux

8.17

2

5

TSCSG

8.17

3

6

Daniel Snowden

8.17

3

8

ICC_RichardEisenberger

8.08

3

9

DWS

8

2

6

MOW

8

2

4

Sneel

8

2

3

Steve Hall

8

2

3

Jan R.

8

2

5

Max Schnell

8

2

3

Nisha Sridhar

8

2

3

John van Leeuwen

8

3

7

jones89

8

3

7

something easier to read

8

3

7

plindgren

8

3

9

HitchHeik

8

3

8

Alexis Ragual

7.83

2

5

Matt_A_

7.75

3

7

NakiPS1

7.75

3

8

Matt McAllister

7.75

3

8

Niel Fletcher

7.67

2

5

Bryan

7.67

2

4

Jerame Caudill

7.67

2

5

Andrey Zvyagin

7.67

3

6

eribaq

7.67

3

8

Tony Uren

7.67

3

6

Geathan

7.67

3

8

Marcos Tsuda

7.67

3

7

Francisco Puig Diaz

7.58

3

9

Thomas Farmer

7.5

2

5

Kryten-68

7.5

3

8

Steve Mahoney

7.5

3

7

cemarsh06

7.5

3

6

Arif Ali

7.5

3

7

Emil Eriksson

7.5

3

5

Forrest Stanley

7.33

2

5

TomKupka

7.33

3

8

Nate Shepard

7.33

3

6

ICC_KFoley

7.33

3

8

BenJT

7.33

3

7

Stephen Brown

7.33

3

6

sfibich

7.25

2

6

Tim Miller

7.25

3

8

Kevin

7.17

3

6

MarcoB78

7

2

6

Tomek A.

7

2

6

Mark Amann

7

2

5

W. Sterling

7

3

7

Robert B

7

3

7

Kieran Walsh

7

3

5

member2712

7

3

4

Bret Ridenour

6.92

3

8

TaylorGibb

6.9

2

7

Shaun Watts

6.83

3

8

Greg Combs

6.83

3

6

Jess Pomfret

6.83

3

7

Mckie

6.8

3

9

Michael Odermatt

6.75

2

6

Leon Nell

6.67

3

7

Clinton Merritt

6.5

2

3

Jeff Schulman

6.33

2

5

Jeffrey Jacobs

6.33

2

5

Scott Button

6.33

2

6

Chris Albert

6.33

2

4

dluke001

6.33

3

7

Matt Swint

6.33

3

7

Shawn bequette

6.17

2

5

Japke

6.08

2

7

Name

6

2

7

Sander

6

2

6

ResetSA

6

2

3

kloinerFeigling83

6

3

6

Tom Parker

5.83

2

5

erunama

5.83

3

7

sebuko

5.75

2

6

266ff21a196fda47d8b035a115fdeb42

5.75

2

6

Clayton Firth

5.67

2

6

greeme

5.67

2

5

Satheesh

5.67

2

6

Vern Anderson

5.67

3

7

Apnea

5.5

2

5

Dennis James

5.5

2

3

lamaar75

5.5

3

6

TheZmann

5.33

2

4

robert broyles

5.33

2

5

u2tb

5.33

2

5

toumi walid

5.33

3

8

Mod10

5.33

3

8

Jonny Earl Grey Lindbom

5.3

2

7

radek

5.25

2

6

Andrew Cameron

5

1

2

RJSN

5

2

3

Jeff Maes

5

2

5

Anthony Rum

5

2

6

Timm Brochhaus

5

2

5

Brian Fraley

5

2

4

Joel Cook

4.83

2

5

Dave Baird

4.83

2

5

Josh Nylander

4.75

2

5

Mike Lambert

4.75

2

6

Mallika Gogulamudi

4.75

2

7

acchong

4.67

1

3

Andy Wyse

4.67

2

6

Sudeep Bhaskar

4.5

1

4

e46d8dd2e1625c7a6182b82bc012a7e0

4.5

3

7

Brian Wuchner

4.42

2

7

Jason Schmidtlein

4.25

1

4

Andrew Gardner

4.25

1

4

Petter Edin

4.17

2

5

evidence

4

1

2

Pavan Hotha

4

1

3

Colyn1337

4

1

1

cphair

4

1

1

Ryan Youngs

4

1

3

joeartz

4

1

4

zacd

4

1

3

Claymonster

4

1

3

Francisco osorio

4

1

3

Filip Rejch

4

1

2

James B. Bizzell

4

1

2

Jay Lockard

4

1

3

Anders Wang

4

2

3

Shaun Gibbs

3.83

2

5

Ola Skjeldal

3.67

1

3

Brett Chandler

3.67

1

3

Vinay Thakur

3.67

3

7

peter bishop

3.58

2

7

Bob__Mule

3.5

1

4

Brendan Erofeev

3.5

1

4

sgatepunk

3.5

1

2

PSLearner

3.5

2

3

ocongil

3.33

1

3

Jasper van der Heijden

3.33

1

3

Tobias

3.33

1

3

70f53217af68ac357dfc1a46739257a6

3.33

1

3

MonitorMan

3.33

1

3

iTodd

3.33

1

3

Jonathan Birkett

3.33

1

3

redi311

3.33

1

3

jeprus

3.25

1

4

Dominic Daigle

3.25

2

8

Dexter

3.17

2

5

TheKidd

3

1

1

skynetx

3

1

3

Jakob Bindslet

3

1

3

Crystal Diaz

3

1

3

mand0

3

1

2

Jude Croyle

3

1

3

Andrew Newman

3

1

2

mitch baker

3

1

3

Tim Hetzel

3

1

2

Björn

3

1

1

Pendrag

3

1

2

Chris Watson

3

2

4

b4d93r

3

2

4

Jay mac

2.33

1

3

Jeremy Dunlop

2.33

1

3

Coderaven

2.33

1

3

a64c64bd8e1fe90b8b024ab272090e32

2.33

1

3

Daed

2.33

1

3

Paul Sweeney

2

1

1

oki

2

1

1

Byty

2

1

3

MrBatchFile

2

2

4

Nico

1.75

1

4

3166f9ba33499b4658123e7b0a84598f

1.67

1

3

Luca Christmann

1.5

1

2

David Granlund

1.33

1

3

Anjan Chidurala

1.33

1

3

2e638c99ea54b4ddb208033083f4ef24

1.33

1

3

Chris Nakagaki (Zsoldier)

1.33

1

3

Gabriel Tapia

1.33

1

3

Marcin Kowalczyk

1.33

1

3

j.vogt

1.33

1

3

TitleRequired

1.33

1

3

John Main

1.33

1

3

le4ne

1.33

1

3

Sean Massey

1.33

1

3

Jason Shaw

1.25

1

4

Eric Ray

1.25

1

4

gary gray

1.2

1

5

TechJLS3

1

1

5

Gary Jackson

1

1

3

Harshul

1

1

1

DisplayName

1

1

2

WizardX

1

1

5

Jeremy Kieler

1

1

3

Advanced Leaderboard of the 2012 Scripting Games: Day 2

$
0
0

This is the Advanced leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Advanced Events

User Name

Total Points

Scripts Rated

Total Ratings

KSchulte

13.5

3

5

Sergey Borisovich

13

3

6

Prosvetov Roman

12.5

3

5

Aleksey Shuvalov

12.17

3

6

Scott1138

12

3

4

ScripterJT

12

3

5

BigTeddy

12

3

6

Mike Hammond

11.5

3

5

Tomek Izydorczyk

11.5

3

5

Ryan Ries

10.5

3

5

Martijn Haverhoek

10

2

4

Albert Fortes

9.33

2

4

Rohn Edwards

9

2

3

Ryan C

9

2

4

Serg

9

3

6

SimonW

8.67

2

5

Jason Wood

8.67

2

4

Tim Parkinson

8.5

2

3

Michał Gajda

8.5

2

3

Jeremy Caauwe

8.5

2

5

J Skiba

8.5

2

3

Glenn Faustino

8.42

2

7

Rob Campbell

8.33

2

5

EasyMac308

8.17

2

5

aml

8.17

3

6

Kevin Hopcroft

8

2

4

LaPhi

8

2

4

Matthew Painter

8

2

3

Nathan Linley

8

2

5

Cameron Wilson

8

3

6

George Kesler

7.67

2

5

Jason Stangroome

7.67

2

6

Kiss Tamás

7.67

2

5

gbdixg

7.67

2

5

Jason Hofferle

7.5

2

3

Jesper Strandberg

7.5

2

3

Billy Angers

7.5

2

3

Peter Heydon

7.5

2

4

Łukasz Kałużny

7.5

2

4

Dan70402

7.5

2

3

Grégory LUCAND

7.5

2

4

sstranger

7.5

2

4

Paulo J

7.5

3

5

Jack Chang

7.33

2

6

Max Lindström

7

2

6

Brent Challis

7

2

3

Carlos Nunez

7

2

4

Tom Parker

7

2

4

marcadamcarter

7

2

3

_Emin_

7

2

4

John Sneddon

7

2

4

vNoob

7

2

7

Kyle Neier

7

2

3

Ed Withers

7

2

4

Serkan Varoglu

6.67

2

5

PeetersOnlineNL

6.67

2

5

Frederick Duemig

6.5

2

3

Jeff Patton

6.5

2

5

Alex McFarland

6.5

2

3

Brad Blaylock

6.5

2

4

Brian Wilhite

6.5

2

4

Robert Mongold

6.5

2

4

Trevor Hayman

6.5

2

4

Patrik Lindström

6.17

2

5

Robert Eder

6

2

3

Ken Hamilton

6

2

7

Steven Hall

6

2

5

Vladimir Stepic

6

2

4

Michael Moore

6

2

4

Vincent Van Hecke

6

2

4

Paul Cunningham

5.67

2

4

Matthew Graeber

5.5

2

4

james seatter

5.5

2

6

Calle E

5.33

2

5

Jon Bryan

5.17

2

5

Dave Griffiths

5

1

2

Jason Scott

5

1

2

Mark Weaver

5

1

2

Yuri Kutovoy

5

2

5

Brian Carr

5

2

3

DamienCharbonnel

5

2

4

ICC_RyanDennis

5

2

6

Cesar Mendoza

4.83

2

5

f2b95d1a805fd4f8623b0d70b6ed3a19

4.67

2

4

Wes Stahler

4.5

1

2

Ken

4.5

1

2

Tom_G

4.5

1

2

Brandon Bettle

4.5

2

3

Anthony Rum

4.5

2

4

Ayo Wu

4.5

2

4

ICC_JDyer

4.33

2

4

UGSING_MattHitchcock

4

1

3

Paul Iddon

4

1

2

Joe D.

4

1

2

Francis D

4

1

3

Thomas Paetzold

4

1

2

jillwi

4

1

3

Anonimista

4

1

2

Jason Cole

4

1

2

Jimmy Mac

4

1

1

Warpig

4

1

2

Justin Sowa

4

1

2

andre2

4

1

2

Cameron Ove

4

1

2

Tobias

4

1

2

T-Bone

4

1

2

Jose Quinones

4

1

2

Claudiu P

4

1

2

smoshea

4

1

2

Fredrik Wall

4

2

6

MOW

4

2

5

Dan Richardson

3.67

1

3

Mikko

3.67

1

3

Mr grnnnx

3.67

1

3

Clinton Merritt

3.67

1

3

jeffrey yao

3.67

1

3

Jaap Brasser

3.67

1

3

MSFTW

3.67

1

3

herschelle

3.67

1

3

Steelwing

3.67

1

3

Chris Oswalt

3.5

1

2

Wolfgang Kais

3.5

1

2

Tony McGee

3.5

1

2

Clint Bergman

3.5

1

2

PeterCS

3.5

1

2

Scott A. Alvarino

3.5

1

2

Yves P

3.5

1

2

Wayne Gault

3.5

1

2

Joel Reed @J_lR_d {AZPOSH}

3.5

1

2

Igway Jacobs

3.5

1

2

Ryan Schlagel

3.5

1

2

Jason Lange

3.5

1

2

Brian Wuchner

3.5

1

2

Matthew BETTON

3.5

1

2

resolver101

3.5

1

2

John Main

3.5

1

2

Matt Gohmann

3.5

1

2

Yuriy Prikhodko

3.5

1

2

j.vogt

3.5

1

2

Sergey Vorontsov

3.5

1

2

ThoamsBiebl

3.5

1

2

Frank Peter Schultze

3.5

1

2

Sam

3.5

1

2

MarkJohnson

3.5

1

2

Patrick Dorsch

3.5

1

2

Miruu

3.5

1

2

Ryan Shafer

3.5

1

2

redi311

3.5

1

2

Greg Martin

3.5

1

2

IJuan

3.5

1

2

Claus Søgaard

3.5

1

2

Chris Stewart

3.5

1

2

Oneill Cameron

3.5

1

2

SassDawe

3.5

1

2

Joshua Fuente

3.5

1

2

jessekozloski

3.5

1

2

BurntChimney

3.5

1

2

PatrikL

3.5

1

2

Bob__Mule

3.33

1

3

Josh

3.33

1

3

kiran reddy

3

1

3

ICC_RDurkin

3

1

1

Nuno Mota

3

1

1

Robert van den Nieuwendijk

3

1

2

Chris Brown

3

1

2

Stephanevg

3

1

2

Jacques

3

1

2

Mike Lambert

3

1

2

Daniel Cruz

3

1

2

Franck RICHARD

3

1

2

Pete Maan

3

1

2

Kirk Cessac

3

1

2

DJ Grijalva

3

1

2

blindrood

3

1

3

David Eilers

3

1

2

Michael Topal

3

1

2

crownedjitter

3

1

2

Dexter

3

1

2

Stijn Callebaut

3

1

2

Jonny Earl Grey Lindbom

3

1

3

Jakob Bindslet

3

1

3

Jiri Formacek

3

1

2

MattBoren

3

1

1

Zach M

3

1

2

Kim Tram

3

1

2

Tom Moser

3

1

2

Frank Migacz

3

1

2

Scripting Scott Saari

3

1

2

ginno

3

1

2

Greg Shay

3

1

2

ofirey

3

1

2

Erin Huligan

3

1

2

Robert de Britto

3

1

2

Gregg Britton

3

1

2

hemanth.damecharla

3

1

2

Pemo

3

1

2

AaronHoover

3

1

1

Ken Lin

3

1

1

Matthew Vidrine

3

1

2

JeremiahC

3

1

2

MSFT-AutomationJason

2.5

1

2

James Tryand

2.5

1

2

Dan Lepine

2.5

1

2

dude9000

2.5

1

2

Sean Decker

2.5

1

2

Sai Prasad Vaddepally

2.5

1

2

Chris Duck

2.5

1

2

Claudio Westerik

2.5

1

2

Perry Harris

2.5

1

2

AZPOSH - Brian T Young

2.5

1

2

Eddy Steenbergen

2.5

1

2

Will Steele

2

1

4

Nathan Cook - AU

2

1

2

Dave Ackroyd @LearnPowerShell

2

1

4

Rich Kusak

2

1

1

BobMule

2

1

2

Joshua Feierman

2

1

2

Franck Malterre

2

1

2

Marcin Kowalczyk

2

1

2

Brentos

2

1

2

skynetx

2

1

2

Jason Milczek

2

1

2

845ebf71ea404155b02971a5b6e8bc8d

2

1

2

WizardX2

2

1

2

TechJLS3

2

1

1

Luca Christmann

1.67

1

3

Rob Dowell

1.5

1

2

El Ryan

1.5

1

2

mand0

1.5

1

2

Internal_IT

1.5

1

2

Filip Rejch

1.5

1

2

Daed

1.5

1

2

Andrew

1.5

1

2

Damon Brinkley

1.5

1

2

Jim Vierra

1.33

1

3

Justin Stokes

1

1

2

Brian T. Jackett

1

1

2

Ákos Kinczel

1

1

2

Johan Åkerström

1

1

2

Sean Brown Houses

1

1

2

Schlauge

1

1

3

Dustin Hedges

1

1

2

Hong

1

1

2

Ken King

1

1

1

Valeriy Aksyonov

1

1

2

Jude Croyle

1

1

2

Chris Nakagaki (Zsoldier)

1

1

2

19691edf5d765a567ae58fb19f113083

1

1

2

2012 Scripting Games Beginner Event 10: Collect Performance Counter Information

$
0
0

 2012 Scripting Games badge

Summary: In Beginner Event 10, you are required to collect performance counter information about your CPU.

About this event

Division

Beginner

Date of Event

4/13/2012 12:01 AM

Due Date

4/20/2012 12:01 AM

Event scenario

You are a network administrator for a small company, and you are attempting to monitor a transient problem with CPU spiking on one of your servers. You decide that rather than running the performance monitor or task manager, you want to use Windows PowerShell to collect the performance counter information. You do not have time to manually choose a bunch of counters, but you want to gather all of the counter information from the processor counter set. You should take three separate readings at five-second intervals. All of the counter information should be appended to a single text file that is named after the server and placed in the Documents special folder. An appropriate output is shown in the image that follows.

Image of command output

Design points

  • You can write the performance counter information directly to a text file named after the server. Place the text file into the Documents special folder. The file name will look like the following: servername_ProcessorCounters.txt.
  • Your command should retrieve all of the performance counter information from the Processor performance counter set.
  • You do not need to write a long convoluted script to meet the requirements of this scenario. You will lose points for long, complicated, hard-to-read scripts.
  • A “one liner” command can be written that will satisfy the requirements of this scenario.
  • You should use native Windows PowerShell commands for this scenario where possible.

2012 Scripting Games links

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 

2012 Scripting Games Advanced Event 10: Create a CSV Log File

$
0
0

 2012 Scripting Games badge

Summary:  In Advanced Event 10, you want to create a CSV log file of all the counters in the Processor counter set.

About this event

Division

Advanced

Date of Event

4/13/2012 12:01 AM

Due Date

4/20/2012 12:01 AM

Event scenario

You are a server admin, and you are concerned about the processor performance of one particular server. You decide to use Windows PowerShell to create a CSV log file of all the counters in the Processor counter set. You decide to take the counter snapshot at two-second intervals for a total of ten snapshots. You plan to analyze the data in a Microsoft Excel spreadsheet. An acceptable output is shown in the figure that follows. Create the CSV file in the Documents special folder for the current logged-on user. The file name should be servername_processorCounters.csv.

Image of command output

Design points

  • Make sure that you include all of the counters for all instances of the processor object.
  • Make sure that the saved CSV file is readable from within Microsoft Excel.
  • Make sure that you get the number of snapshots with the prescribed time between snapshots.
  • This can be a “one liner” single logical command. Do not write complex, difficult-to-understand script because you will lose points.

2012 Scripting Games links

2012 Scripting Games: All Links on One Page

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Good luck as you compete in this year’s Scripting Games. We wish you well.

Ed Wilson, Microsoft Scripting Guy 

Randomly Drawn Prize Winners: 2012 Scripting Games Day 4

$
0
0

Thank you for entering the 2012 Scripting Games. A special thank you to our wonderful sponsors for making these prizes possible. Please be sure to visit the sponsors page for more information about these awesome companies. We will send the prize winners an email with the pertinent information about their prizes soon.

Nathan Lare

1  ebook from O’Reilly Media (ARV $20.00)

Daniel Bicho

1  ebook from O’Reilly Media (ARV $20.00)

Rob Campbell

1  ebook from O’Reilly Media (ARV $20.00)

NSlearningPS

1  ebook from O’Reilly Media (ARV $20.00)

Jason Stangroome

1  ebook from O’Reilly Media (ARV $20.00)

mand0

1 ebook from Manning (ARV $40.00)

Trevor Watkins

1 ebook from Manning (ARV $40.00)

Eleftheria Theologou

1 ebook from Manning (ARV $40.00)

Mckie

1 ebook from Manning (ARV $40.00)

David Blackmore

1 ebook from Manning (ARV $40.00)

GCaporale

1 each Amazon Gift ecard from BeyondTrust (ARV $50.00)

Leon Nell

1 copy PrimalForms 2011 from SAPIEN Technologies (ARV $299)

J Skiba

1 copy PowerWF from Devfarm Software (ARV $499)

 2012 Scripting Games badge

Advanced Leaderboard of the 2012 Scripting Games After 5 Days

$
0
0

This is the Advanced leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Advanced Events

User Name

Total Points

Scripts Rated

Total Ratings

KSchulte

23.5

5

7

Prosvetov Roman

22.5

5

8

Sergey Borisovich

22

5

8

Aleksey Shuvalov

21.17

5

8

BigTeddy

20

5

8

Mike Hammond

19.5

5

7

Ryan Ries

19

5

8

Michał Gajda

18.5

4

6

Glenn Faustino

17.42

4

9

Igway Jacobs

16.5

4

6

Scott1138

16.5

4

6

Ed Withers

16

4

7

Nathan Linley

16

4

7

Serg

16

5

8

Jason Stangroome

15.67

4

8

Tomek Izydorczyk

15.5

4

6

Jack Chang

15.33

4

8

Mikko

15.17

4

7

John Sneddon

15

4

6

gbdixg

14.67

4

7

vNoob

14

4

9

ICC_RyanDennis

14

4

8

Albert Fortes

13.33

3

5

SimonW

12.67

3

6

Jeremy Caauwe

12.5

3

6

Rob Campbell

12.33

3

7

EasyMac308

12.17

3

6

aml

12.17

4

7

ScripterJT

12

3

5

Lars Seinwill

12

3

5

Cameron Wilson

12

4

7

George Kesler

11.67

3

6

Serkan Varoglu

11.67

3

6

Nuno Mota

11.5

3

4

Łukasz Kałużny

11.5

3

5

Matthew Graeber

11.5

4

6

Ayo Wu

11.5

4

6

Paulo J

11.5

4

6

Kyle Neier

11

3

4

Trevor Hayman

10.5

3

5

Matthew BETTON

10.5

3

5

Frederick Duemig

10.5

3

4

Martijn Haverhoek

10

2

4

Michael Moore

10

3

5

Vladimir Stepic

10

3

5

Vincent Van Hecke

10

3

5

james seatter

9.5

3

8

Francis D

9

2

4

Rohn Edwards

9

2

3

Ryan C

9

2

4

DamienCharbonnel

9

3

5

Michael Topal

9

3

4

Jason Wood

8.67

2

4

Tim Parkinson

8.5

2

3

J Skiba

8.5

2

3

Jason Cole

8

2

4

DJ Grijalva

8

2

4

Matthew Painter

8

2

3

Kevin Hopcroft

8

2

4

Kiss Tamás

7.67

2

5

Jesper Strandberg

7.5

2

3

Jason Hofferle

7.5

2

3

Peter Heydon

7.5

2

4

Billy Angers

7.5

2

3

sstranger

7.5

2

4

Grégory LUCAND

7.5

2

4

Daniel Howe

7.5

2

3

Daniel Cruz

7

2

4

marcadamcarter

7

2

3

Thomas Paetzold

7

2

3

_Emin_

7

2

4

Brent Challis

7

2

3

Max Lindström

7

2

6

Carlos Nunez

7

2

4

Tom Parker

7

2

4

PeetersOnlineNL

6.67

2

5

Jeff Patton

6.5

2

5

Alex McFarland

6.5

2

3

Yves P

6.5

2

3

Brian Wilhite

6.5

2

4

Robert Mongold

6.5

2

4

Brad Blaylock

6.5

2

4

Patrik Lindström

6.17

2

5

Robert Eder

6

2

3

Sean Decker

6

2

4

Ken Hamilton

6

2

7

Paul Cunningham

5.67

2

4

Internal_IT

5.5

2

3

Calle E

5.33

2

5

Jon Bryan

5.17

2

5

Dave Griffiths

5

1

2

Jason Scott

5

1

2

266ff21a196fda47d8b035a115fdeb42

5

1

1

Mark Weaver

5

1

2

Brian Carr

5

2

3

Yuri Kutovoy

5

2

5

Cesar Mendoza

4.83

2

5

f2b95d1a805fd4f8623b0d70b6ed3a19

4.67

2

4

Wes Stahler

4.5

1

2

Ken

4.5

1

2

Tom_G

4.5

1

2

Brandon Bettle

4.5

2

3

Anthony Rum

4.5

2

4

Damon Brinkley

4.5

2

4

blindrood

4.5

2

5

ICC_JDyer

4.33

2

4

UGSING_MattHitchcock

4

1

3

Anders Wang

4

1

1

Paul Iddon

4

1

2

Joe D.

4

1

2

jillwi

4

1

3

Anonimista

4

1

2

Jimmy Mac

4

1

1

Warpig

4

1

2

Justin Sowa

4

1

2

Cameron Ove

4

1

2

Tobias

4

1

2

T-Bone

4

1

2

Jose Quinones

4

1

2

Claudiu P

4

1

2

smoshea

4

1

2

Scripting Scott Saari

4

1

1

Fredrik Wall

4

2

6

Justin Stokes

4

2

3

hemanth.damecharla

4

2

3

Dan Richardson

3.67

1

3

Mr grnnnx

3.67

1

3

Clinton Merritt

3.67

1

3

jeffrey yao

3.67

1

3

Jaap Brasser

3.67

1

3

herschelle

3.67

1

3

MSFTW

3.67

1

3

Steelwing

3.67

1

3

Chris Oswalt

3.5

1

2

Wolfgang Kais

3.5

1

2

PeterCS

3.5

1

2

Tony McGee

3.5

1

2

Clint Bergman

3.5

1

2

Wayne Gault

3.5

1

2

Joel Reed @J_lR_d {AZPOSH}

3.5

1

2

Yuriy Prikhodko

3.5

1

2

Ryan Schlagel

3.5

1

2

Jason Lange

3.5

1

2

Brian Wuchner

3.5

1

2

resolver101

3.5

1

2

John Main

3.5

1

2

Matt Gohmann

3.5

1

2

Sergey Vorontsov

3.5

1

2

Miruu

3.5

1

2

Ryan Shafer

3.5

1

2

MarkJohnson

3.5

1

2

Patrick Dorsch

3.5

1

2

ThoamsBiebl

3.5

1

2

Frank Peter Schultze

3.5

1

2

Sam

3.5

1

2

redi311

3.5

1

2

Greg Martin

3.5

1

2

IJuan

3.5

1

2

Chris Stewart

3.5

1

2

Oneill Cameron

3.5

1

2

Claus Søgaard

3.5

1

2

SassDawe

3.5

1

2

Joshua Fuente

3.5

1

2

jessekozloski

3.5

1

2

BurntChimney

3.5

1

2

PatrikL

3.5

1

2

Bob__Mule

3.33

1

3

Josh

3.33

1

3

kiran reddy

3

1

3

ICC_RDurkin

3

1

2

Robert van den Nieuwendijk

3

1

2

Pete Maan

3

1

2

Chris Brown

3

1

2

Stephanevg

3

1

2

Jacques

3

1

2

Mike Lambert

3

1

2

Franck RICHARD

3

1

2

Kirk Cessac

3

1

2

David Eilers

3

1

2

Dexter

3

1

2

crownedjitter

3

1

2

Stijn Callebaut

3

1

2

Jonny Earl Grey Lindbom

3

1

3

Jakob Bindslet

3

1

3

Jiri Formacek

3

1

2

MattBoren

3

1

2

Zach M

3

1

2

Kim Tram

3

1

2

Tom Moser

3

1

2

ginno

3

1

2

Greg Shay

3

1

2

ofirey

3

1

2

Erin Huligan

3

1

2

Pemo

3

1

2

Robert de Britto

3

1

2

Gregg Britton

3

1

2

Frank Migacz

3

1

2

Scripting Scott Saari

3

1

2

AaronHoover

3

1

2

JeremiahC

3

1

2

Ken Lin

3

1

2

Matthew Vidrine

3

1

2

MSFT-AutomationJason

2.5

1

2

James Tryand

2.5

1

2

Dan Lepine

2.5

1

2

dude9000

2.5

1

2

Chris Duck

2.5

1

2

Perry Harris

2.5

1

2

Claudio Westerik

2.5

1

2

Eddy Steenbergen

2.5

1

2

AZPOSH - Brian T Young

2.5

1

2

Dan Jakubczak

2

1

1

Will Steele

2

1

4

Nathan Cook - AU

2

1

2

Dave Ackroyd @LearnPowerShell

2

1

4

Rich Kusak

2

1

2

Joshua Feierman

2

1

2

BobMule

2

1

2

Marcin Kowalczyk

2

1

2

Franck Malterre

2

1

2

Brentos

2

1

2

skynetx

2

1

2

Jason Milczek

2

1

2

845ebf71ea404155b02971a5b6e8bc8d

2

1

2

WizardX2

2

1

2

jcriswell

2

1

2

Luca Christmann

1.67

1

3

Rob Dowell

1.5

1

2

El Ryan

1.5

1

2

mand0

1.5

1

2

TechJLS3

1.5

1

2

Daed

1.5

1

2

Filip Rejch

1.5

1

2

Andrew

1.5

1

2

Jim Vierra

1.33

1

3

Brian T. Jackett

1

1

2

Ákos Kinczel

1

1

2

Johan Åkerström

1

1

2

Schlauge

1

1

3

Dustin Hedges

1

1

2

Hong

1

1

2

Sean Brown Houses

1

1

2

Ken King

1

1

2

Valeriy Aksyonov

1

1

2

Jude Croyle

1

1

2

Chris Nakagaki (Zsoldier)

1

1

2

David Blackmore

1

1

2

 



Beginner Leaderboard of the 2012 Scripting Games After 5 Days

$
0
0

This is the Beginner leaderboard of the 2012 Scripting Games. Keep in mind that the rankings are constantly changing throughout the day, as event submissions are graded by the judges. All entries will continue to be graded by judges until 12:01 A.M. Pacific Time (UTC-8) on April 23, 2012. At that time, no more scripts will be evaluated, and the leaderboard will be finalized.

How are scripts scored? Learn more about judging criteria.

 2012 Scripting Games badge

Top Submitters for the Beginner Events

User Name

Total Points

Scripts Rated

Total Ratings

Mike F Robbins

24.05

5

16

Chris Manning @pbchris

23.67

5

12

David OBrien

23

5

12

Mathieu Boulard

22.75

5

14

Adam Funck

22.75

5

11

Nathan Mayberry

22.67

5

9

Sahal Omer

22.67

5

8

Zak Humphries

22.58

5

11

ruskie

22.58

5

12

Dawn Villejoin

22.55

5

17

Srikanth

22.17

5

13

SLevenberg

22

5

10

arnold moreno

21.87

5

13

Carl

21.75

5

16

JoeTea

21.75

5

10

Andy Bidlen

21.67

5

12

Eric Pankowski

21.5

5

13

yellowscope

21.5

5

15

andre

21.42

5

12

ngebhar2

21.33

5

13

Nadeem Vance

21.33

5

9

Eleftheria Theologou

21.27

5

13

Mouton

21.25

5

11

Stephen Correia

21.17

5

10

clbarnett

21

5

13

Maciej

21

5

14

James McNeil

20.92

5

13

qsilverx

20.9

5

14

Mr_Motown

20.75

5

14

AmandaD

20.75

5

11

DrLe

20.75

5

14

Andy Mello

20.67

5

12

Derek Schauland

20.67

5

12

Mark P

20.67

5

13

Joshua Taylor

20.6

5

14

eklime

20.58

5

12

emekm

20.5

5

12

James White

20.5

5

15

Oleg Suchkov

20.4

5

12

JeffWouters

20.38

5

18

Paul Hiles

20.33

5

12

James Berkenbile

20.33

5

12

Grzegorz Kulikowski

20.33

5

11

Jhonny Yamaniha

20.25

5

15

Cliff Harrison

20.25

5

14

Matt benton

20.17

5

11

NCoppersmith

20.17

5

11

Shevek

20.17

5

10

Daniel Headley

20.17

5

8

Jordan Davis

20.08

5

13

Don Hunt

20

5

12

honeybadger

20

5

10

ICC_mworthley

20

5

14

ScriptingWife

19.92

5

15

Luke Forder

19.92

5

14

Neil Clinch

19.75

4

7

Tim Muessig

19.75

5

13

Duffman

19.75

5

13

Tim Watson

19.7

5

15

Vinay Bhandari

19.58

5

10

Marcin Pietras

19.5

4

7

TechguyTJ

19.5

5

13

Chris-D

19.5

5

11

SM Yeoh

19.5

5

11

AballahSonDis

19.5

5

11

Andreas Engkvist

19.5

5

12

Nathan Lare

19.5

5

11

BradC

19.5

5

11

MikeHowden

19.42

5

11

Matt Tilford

19.33

5

12

Brian Sabatini

19.33

5

12

Brian Bohanon

19.33

5

12

Werner

19.25

5

13

Ken Wilson

19.17

5

15

Gica

19.15

5

13

BTmuney

19.08

5

13

Thiyagu

19

4

6

tyoung

19

5

13

Scott Baker

18.92

5

13

Jon McCormick

18.83

5

13

Lotte

18.83

5

11

David Waderich

18.83

5

11

Mooseade

18.8

5

13

James Stallwood

18.75

5

13

vNiklas

18.75

5

12

JeremyB

18.75

5

13

Andrew Morgan

18.75

5

12

wschoier

18.67

4

8

Jason Omar

18.58

5

15

aalaminos

18.58

5

12

Sigitas Grėbliūnas

18.5

4

7

CraigJahnke

18.5

5

10

Daniel Killian

18.5

5

12

AnotherPoShBlog

18.4

5

11

Lido Paglia

18.33

4

8

Chris Seiter

18.33

5

9

GCaporale

18.25

5

14

Jeremy Cox

18.17

5

12

Fabio Jr

18.17

5

10

SdeDot

18.17

5

13

Ifiok Moses

18.17

5

12

Daniel Thompson

18.17

5

13

John Grenfell

18.08

5

12

Alexis Ragual

18

4

10

BernhardG

18

5

11

ckrull

18

5

14

L4NM4N

18

5

12

NakiPS1

18

5

13

Norman Manoh

18

5

10

jaydee

18

5

12

rumart

18

5

13

Emil Eriksson

18

5

10

Dave Maldonado

17.92

4

9

mvanhorenbeeck

17.92

5

15

Geathan

17.87

5

13

mark_@_li

17.83

4

9

NGelotte

17.67

4

7

Charlie Jacobson

17.67

4

8

cemarsh06

17.67

5

13

Will Nevis

17.58

5

14

Yves PASCAULT

17.5

5

10

Xander Solis

17.5

5

13

DaveyK

17.5

5

14

Tony Rad

17.5

5

14

Shawn Melton

17.33

4

10

ICC_jruff

17.33

4

9

Andrew Dauncey

17.33

5

9

member2712

17.33

5

12

Dexter Dhami

17.25

4

10

Clayton McKenzie

17.25

5

15

MarkIsBack

17.17

5

13

Pradeep Rawat

17.17

5

14

Erica Miles

17.17

5

12

blahcubed

17

4

7

John Russell

17

5

11

mtb44

17

5

13

Dan

16.92

5

12

Daniel Bicho

16.92

5

12

something easier to read

16.83

5

12

Derrick Michelson

16.83

5

11

Steve Mahoney

16.75

5

13

ICC_RichardEisenberger

16.75

5

14

Tony Uren

16.67

5

11

TSCSG

16.67

5

11

Tyson J. Hayes

16.67

5

11

John OHarra

16.65

5

14

dluke001

16.58

5

11

Matt Swint

16.58

5

13

David Christian

16.5

5

11

Mads Hjort Larsen

16.5

5

12

Dominic Leonard

16.42

5

12

shiv

16.42

5

12

Nisha Sridhar

16.33

4

7

Chris Keim

16.33

5

12

Nate Shepard

16.33

5

9

Jason Y.

16.33

5

13

eribaq

16.27

5

14

Andrey Zvyagin

16.25

5

12

Bastien B

16.25

5

14

catremor

16.25

5

12

Shaun Watts

16.25

5

12

Steve Hall

16.17

4

8

BenJT

16.17

5

12

Michael Moore

16

4

10

Jess Pomfret

16

5

11

Robert B

16

5

13

Wouter Beens

15.92

5

12

BreakDown

15.83

5

15

ICC_KFoley

15.83

5

13

Phill McSherry

15.83

5

14

jarheadf23

15.75

4

9

nyoro2

15.67

4

8

Elmerp

15.67

4

7

W. Sterling

15.67

5

13

The Awesome-Machine.NET

15.67

5

12

Rich Oswald

15.67

5

12

Dennis James

15.5

4

7

Sidewinder

15.5

5

12

Trevor Watkins

15.5

5

12

Matt McAllister

15.5

5

13

Megha Kuruvilla

15.17

4

9

HitchHeik

15.17

5

14

Julie Andreacola

15.08

4

10

Aaron Bednar

15

4

9

Timo Skupin

15

5

14

Kryten-68

15

5

13

Zia

14.83

5

13

Marty

14.8

4

11

Daniel Dittenhafer

14.67

5

12

Riwe

14.67

5

13

John

14.6

3

8

aaron d

14.5

5

11

Clancy Wendt

14.5

5

11

Sai Prasad Vaddepally

14.33

4

9

Leon Nell

14.33

5

13

mrgif1

14

3

5

real fastcomputer

14

4

8

jones89

13.92

5

13

Scott Alvarino

13.83

4

9

John van Leeuwen

13.58

5

12

Mod10

13.58

5

13

toumi walid

13.5

5

13

Daniel Snowden

13.42

4

11

lamaar75

13.33

5

13

Vern Anderson

13.17

5

12

Max Schnell

13

3

4

Joe Keohan

13

5

11

Marcos Tsuda

12.92

4

9

Kieran Walsh

12.67

4

8

Stephen Brown

12.33

4

8

octavmarius

12.17

3

8

jbrek

12.17

4

10

Roy M

12.17

4

11

NSlearningPS

12

3

7

Matt Vidrine

12

3

7

Pendrag

12

3

5

therceg

11.67

3

7

Chris Albert

11.33

3

5

mand0

11.33

3

5

Shawn bequette

11.33

4

9

ResetSA

10.83

4

8

e46d8dd2e1625c7a6182b82bc012a7e0

10.67

5

12

Patrik Lindström

10.5

3

8

Bret Ridenour

10.5

4

11

MOW

10.5

4

7

Steven Neel

10

2

3

erunama

10

5

12

266ff21a196fda47d8b035a115fdeb42

9.75

3

9

Mckie

9.47

4

12

Vinay Thakur

9.33

5

12

Chuck Lathrope

9.27

3

9

Hov Arve

9.17

3

8

Darren Maspero

9

2

8

Colyn1337

9

2

2

cphair

9

2

4

Shaun Gibbs

9

3

7

Peter Heydon

8.92

2

7

Dennis Jarjosa

8.42

2

7

DWS

8.42

2

7

Matt_A_

8.42

3

8

lvimeux

8.33

2

6

Jan R.

8.33

2

6

Arif Ali

8.33

3

8

Yuri Kutovoy

8.25

3

10

plindgren

8.25

3

10

Niel Fletcher

8

2

6

Thomas Farmer

8

2

6

Sneel

8

2

3

Jerame Caudill

8

2

6

TheKidd

8

2

2

Anders Wang

8

3

5

Tim Miller

7.92

3

9

sfibich

7.75

2

7

Francisco Puig Diaz

7.75

3

10

Bryan

7.67

2

4

Forrest Stanley

7.67

2

6

TomKupka

7.58

3

9

Tomek A.

7.5

2

8

MarcoB78

7.42

2

7

TaylorGibb

7.4

2

8

Kevin

7.33

3

7

Brian Fraley

7.25

3

8

Michael Odermatt

7.08

2

7

Jeffrey Jacobs

7

2

6

Jeff Schulman

7

2

6

EDW

7

2

4

Mark Amann

7

2

5

Clinton Merritt

7

2

4

Greg Combs

7

3

7

Sander

6.83

2

7

Scott Button

6.83

2

7

Tom Parker

6.67

2

6

Name

6.6

2

8

kloinerFeigling83

6.58

3

8

Japke

6.5

2

8

u2tb

6.33

2

6

Clayton Firth

6.25

2

7

Jeff Maes

6

2

6

oki

6

2

3

Richard Holman

6

2

2

Harshul

6

2

2

sebuko

5.75

2

6

greeme

5.67

2

6

Apnea

5.67

2

6

Satheesh

5.67

2

7

Timm Brochhaus

5.5

2

6

Jonny Earl Grey Lindbom

5.47

2

8

radek

5.42

2

7

TheZmann

5.33

2

4

robert broyles

5.33

2

6

Dave Baird

5.33

2

6

Anthony Rum

5.25

2

7

Mike Lambert

5.25

2

7

Andrew Cameron

5

1

2

Dean Grant

5

1

2

Andy Wyse

5

2

7

Brian Wuchner

5

2

8

Joel Cook

5

2

6

Mallika Gogulamudi

5

2

8

RJSN

5

2

3

acchong

4.75

1

4

Josh Nylander

4.75

2

6

Ken King

4.5

1

2

Sudeep Bhaskar

4.5

1

4

Petter Edin

4.33

2

6

Andrew Gardner

4.25

1

4

Jason Schmidtlein

4.25

1

4

joeartz

4

1

4

Ryan Youngs

4

1

3

zacd

4

1

3

Claymonster

4

1

3

Francisco osorio

4

1

3

Filip Rejch

4

1

2

James B. Bizzell

4

1

2

Jay Lockard

4

1

3

evidence

4

1

3

Pavan Hotha

4

1

3

peter bishop

4

2

8

Dominic Daigle

3.85

2

9

Brett Chandler

3.67

1

3

Ola Skjeldal

3.67

1

3

PSLearner

3.67

2

4

Chris Watson

3.67

2

5

Bob__Mule

3.5

1

4

Brendan Erofeev

3.5

1

4

sgatepunk

3.5

1

2

ocongil

3.33

1

3

Jasper van der Heijden

3.33

1

3

Tobias

3.33

1

3

70f53217af68ac357dfc1a46739257a6

3.33

1

3

MonitorMan

3.33

1

3

iTodd

3.33

1

3

Jonathan Birkett

3.33

1

3

redi311

3.33

1

3

Dexter

3.33

2

6

b4d93r

3.33

2

5

jeprus

3.25

1

4

skynetx

3

1

3

Jude Croyle

3

1

3

Jakob Bindslet

3

1

3

Andrew Newman

3

1

2

mitch baker

3

1

3

Crystal Diaz

3

1

3

Tim Hetzel

3

1

2

Björn

3

1

1

Jay mac

2.33

1

3

a64c64bd8e1fe90b8b024ab272090e32

2.33

1

3

Daed

2.33

1

3

Jeremy Dunlop

2.33

1

3

Coderaven

2.33

1

3

MrBatchFile

2.33

2

5

Byty

2

1

3

Paul Sweeney

2

1

1

Nico

1.75

1

4

3166f9ba33499b4658123e7b0a84598f

1.67

1

3

Luca Christmann

1.67

1

3

le4ne

1.5

1

4

Sean Massey

1.33

1

3

David Granlund

1.33

1

3

Anjan Chidurala

1.33

1

3

Chris Nakagaki (Zsoldier)

1.33

1

3

2e638c99ea54b4ddb208033083f4ef24

1.33

1

3

Gabriel Tapia

1.33

1

3

Marcin Kowalczyk

1.33

1

3

j.vogt

1.33

1

3

TitleRequired

1.33

1

3

John Main

1.33

1

3

Jason Shaw

1.25

1

4

Gary Jackson

1.25

1

4

Eric Ray

1.25

1

4

gary gray

1.2

1

5

Jeremy Kieler

1

1

3

TechJLS3

1

1

5

DisplayName

1

1

2

WizardX

1

1

5

 

Simplify Your PowerShell Code by Using a Compound Where Clause

$
0
0

Summary: Microsoft Scripting Guy, Ed Wilson, talks about a couple of issues he saw while grading scripts for the 2012 Windows PowerShell Scripting Games.

Microsoft Scripting Guy, Ed Wilson, is here. The Scripting Wife and I are in Atlanta for SQL Saturday #111. I will be talking about Windows PowerShell and SQL best practices. One of the great things about the Scripting Games is seeing what other people are doing. When you are the Microsoft Scripting Guy, it is good to see where people still have some confusion, and then use that information to generate ideas for blog posts. I am not alone in this endeavor. I saw a tweet the other day that said the person was generating a huge list of subjects for blog posts as a result of the 2012 Scripting Games. Today I want to look at a few things that caused me to repeat myself over and over again as I was grading scripts.

The mystery of the compound Where clause

In Windows PowerShell 3.0, we have simplified the simple Where clause. I am not going to write about that right now, but it is enough to say that when you have a single condition, it is easier to write in Windows PowerShell 3.0 than in Windows PowerShell 2.0. But there are many times when you want to use a compound Where clause. For example, Beginner Event 3 requires you to find running services that also support a Stop command. I saw lots of scripts where the person obviously did not know about using a compound Where clause. Here is one such example:

gsv -computername localhost | where {($_.status -eq "Running") -and ($_.CanStop -eq $true)}

Now, there is nothing wrong with this line of code—in fact, it meets the needs of the scenario, and it works perfectly fine. But the code can be simplified by using a compound Where clause. Simple and compound do not often go together, but they do here. Here is the way I would write the Where clause:

where { $_.status -eq 'running' -and $_.canstop }

Notice, that instead of having two separate groupings, I in fact, have no grouping at all. (The grouping is the parentheses.) The compound Where clause says where the status of the current object (the $_ represents, the current object in the pipeline) is equal to Running. It also says, AND $_.CanStop. (I will talk about this in a little bit.) Where is an alias for the Where-Object cmdlet. The question mark (?) is also an alias for the Where-Object cmdlet. But notice that in the script block of the Where-Object cmdlet, condition one is equal to Running, AND condition two exists.

What is a Boolean value, and what do I do about it?

In the get running services that also accept a Stop command event, there is a property called CanStop that exists on the System.ServiceProcess.ServiceController object. This CanStop property is shown here.

PS C:\Users\ed.IAMMRED> Get-Service | Get-Member canstop

   TypeName: System.ServiceProcess.ServiceController

Name    MemberType Definition

----    ---------- ----------

CanStop Property   System.Boolean CanStop {get;}

Notice that under the definition, it says that the CanStop property is a System.Boolean. Boolean values are On/Off, True/False, -1/0, Enabled/Disabled, Exist/Don’t exist, and so on. One of the cool things about Windows PowerShell, is that if something exists, and it is a Boolean value, I only need to say Where plus ThePropertyOfTheObject. Let’s go back to Beginner Event 3. So, in the long version of the Where clause, the writer had the following:

where {($_.status -eq "Running") -and ($_.CanStop -eq $true)}

As I mentioned, it works. But it can be shortened by saying –and $_.CanStop. Here we are saying, “Does the CanStop property exist on the object?” If it does, this is all we want. Therefore, I can reduce this by saying, “Does it exist?” This is shown here.

where { $_.status -eq 'running' -and $_.canstop }

The nice thing is that I can negate the Boolean value. For example, if I want the running services that do NOT accept a Stop command, I have several choices. I would probably use the Not operator (!). This is shown here.

where { $_.status -eq 'running' -AND !$_.canstop }

Most of the time, I will use grouping around the Boolean value to make the code a bit clearer. This is shown here.

where { $_.status -eq 'running' -AND !($_.canstop)

If you do not like the exclamation point (!) for the Not operator, you also can use the –not operator. This is shown here.

where { $_.status -eq 'running' -AND -not $_.canstop }

Once again, I generally put grouping around the Boolean value to make the command easier to read (at least for me). This is shown here.

where { $_.status -eq 'running' -AND -not ($_.canstop) }

Not handling the default

I also saw lots of scripts that had a hardcoded value for ComputerName. Some said Server01, others said NameOfRemoteServer. I am calling this out because it is a problem. It causes someone to immediately edit the script before they can run it. I wrote a really good blog about this issue that I will refer you to: Create and Use Default Values in PowerShell Scripts.

Well, that is about it for now. There are thousands of scripts that need to be graded in the next few days. So until tomorrow, have a great day.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy

Randomly Drawn Prize Winners: 2012 Scripting Games Day 5

$
0
0

Thank you for entering the 2012 Scripting Games. A special thank you to our wonderful sponsors for making these prizes possible. Please be sure to visit the sponsors page for more information about these awesome companies. We will send the prize winners an email with the pertinent information about their prizes soon.

Wouter Beens

1 ebook from Manning (ARV $40.00)

Thiyagu

1 ebook from Manning (ARV $40.00)

CraigJahnke

1 ebook from Manning (ARV $40.00)

Sam

1 ebook from Manning (ARV $40.00)

Grégory LUCAND

1 ebook from Manning (ARV $40.00)

Glenn Faustino

1  ebook from O’Reilly Media (ARV $20.00)

Scott1138

1  ebook from O’Reilly Media (ARV $20.00)

George Kesler

1  ebook from O’Reilly Media (ARV $20.00)

Joshua Taylor

1  ebook from O’Reilly Media (ARV $20.00)

John

1  ebook from O’Reilly Media (ARV $20.00)

Rohn Edwards

1  Windows PowerShell 2.0:TFM ebook from SAPIEN Technologies (ARV $34.99)

JeremyB

1 copy PowerShell Plus Professional Edition version 4.0 from Idera (ARV $199)

Robert Eder

1 each Amazon Gift ecard from BeyondTrust (ARV $50.00)

 


 
2012 Scripting Games badge

Scripting Games Wrap Up Part 2: Neatness Counts and Other Stuff

$
0
0

Summary: Microsoft Scripting Guy, Ed Wilson, talks about the importance of formatting your Windows PowerShell code, returning objects, and other stuff.

Microsoft Scripting Guy, Ed Wilson, is here. It is Sunday in Charlotte, North Carolina. I have been busy grading scripts since early this morning. The last event, Event 10, appeared on April 13, but there is still one more week during which time contestants are turning in their final scripts. This is the time when the leaderboard will begin to dramatically shift. So I still cannot talk about issues from the last five events, but I can talk about some of the earlier events.

Neatness counts

I am not talking about being really crazy and making sure that everything lines up perfectly. I had a professor in college who used to take a ruler to the green bar paper we had to turn in, and he subtracted 1 point for each space that was not perfectly aligned. Regardless of how the code ran, it had to look perfect—in fact; it had to print out perfectly. I am NOT talking about that at all.

But, keep in mind that a fundamental concept is that you should be able to read and understand your script. If you can do that, you reduce the amount of troubleshooting by at least 50% (and no, I have not actually measured that—it is more of a guess). It is in my Windows PowerShell Best Practices book in the chapter about troubleshooting scripts.

So, what am I talking about when I talk about neatness? Here are a few quick guidelines:

  1. Avoid making someone scroll. Keep your code to the width of your screen, so that it does not flow off of the screen. When code is hidden from view, it is easy to make mistakes.
  2. Avoid using line continuation marks. The grave accent ( ` …I call it a backtick) is line continuation. It makes code hard to read, and is especially error prone. I have had many scripts that ran perfectly on my computer. Then when I posted them to the Hey, Scripting Guy! Blog, they no longer worked because it picked up an extra space or something. The grave accent is picky, and it is best to avoid it if possible.
  3. Break your code at the pipe ( | ) character. Leave your pipe characters on the right, and thus avoid line continuation.
  4. Indent subordinate clauses. Let’s say that you have an IF statement and your condition on one line. Now you have an ELSE clause. Intent the ELSE clause. How much? I generally use two spaces. The reason is that it is a visible indicator of an indent (it is easier to spot than one space), but it does not use as much space as a tab. Remember Rule 1: Keep your code narrow and avoid scrolling. If you use eight spaces for a tab, and you press tab tab tab, you just ate up 24 spaces, and you do not have much room for code after that. So I keep my indents to two spaces.
  5. Avoid using the Tab key for your tabs. This is because an actual Tab key (ASCII 9) is different than a space (ASCII 32). Some editors allow you to substitute spaces for the Tab key, and they even allow you to specify how many spaces to insert when you do hit the Tab key. This is useful, because some mediums do not correctly interpret a tab when it shows up in code. For this reason, I avoid using the actual Tab key, and I instead use spaces.
  6. Consider where you put the braces ({ }). This is really a personal preference. I played with putting the braces on their own lines, and lining up the opening and the closing brace. I fact, I still often do that. But at times, when the script is short, I will open the brace on the beginning line, and close it at the end of the last line; and therefore, the braces are not on their own individual lines.
  7. Avoid in-line comments. Instead put the comments on the line ahead of the line it comments. This is because when code is moved around, edited, or whatever, an in-line comment can break the code that follows. In addition, in-line comments are not as noticeable as comments on their own individual lines.

Return an object…please

It is best if you return an object. This is because anyone who uses your code can pipe the results to other cmdlets, such as Where-Object, Sort-Object, or even Format-Table or Out-GridView. But they are not required to do so. If you spend a lot of time in your script creating your own custom formatting, the person who uses your code cannot process it further. When you send something to Format-Table, Format-List, or Format-Wide, you are done. No further processing can be done because you no longer have the original object—you have a series of formatting objects that behave completely differently than the original object. When you return an object, you permit others to use your code in the way that they want to use it. It makes the eco-system better.

Meet the requirements

If my boss asks me to write a script that does x, y, and z, and I spend two days creating a really cool script that does a, b, and c, my boss is not going to be too happy. Because although he now has a script that does a, b, and c, he still needs a script to do x, y, and z. Part of developing solutions involves first analyzing the requirements, determining the inputs and the outputs from the script, examining use case scenarios, and finally, beginning to write the code. In fact, in many projects, the actual coding time is far less than the other tasks put together.

Well, that is about all I have time for today. I have a lot of scripts to grade. Take care, and I will see you tomorrow when I will have expert solutions to Beginner and Advanced Events 1.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

Expert Commentary: 2012 Scripting Games Beginner Event 1

$
0
0

Summary: Microsoft Windows PowerShell MVP, Thomas Lee, provides expert commentary for 2012 Scripting Games Beginner Event 1.

Microsoft Scripting Guy, Ed Wilson, is here. Thomas Lee is the expert commentator for Beginner Event 1.

Photo of Thomas Lee

Thomas is an IT Pro with over 40 years experience. He’s a WindowsPowerShell MVP, and he is very busy writing, consulting, and training for some of the key Microsoft technologies, including Windows PowerShell, Lync, and Windows Server and client. In his spare time, he lives in a small cottage in the UK with his wife, daughter, and a nice wine cellar. He has a large collection of Grateful Dead live recordings (which are managed, of course, by using Windows PowerShell).

Blogs:

Under The Stairs

PowerShell Scripts Blog

Twitter: @doctordns

I really enjoy the annual Scripting Games contest. It is an opportunity to show off one’s scripting skills and learn some things in the bargain. As a judge, I cannot enter, but I still get a chance to see what other folks manage to make of each of the tasks. I love looking at how others solve the various problems, and I often learn myself!

When coming up with a solution to the scripting games events, there are a couple of aspects you need to think about. First, especially for the beginner category, it is important that your solution do what your boss wanted. In this first task, the boss wants a list of processes, so getting a list of services would be of little use.

At the same time, it is worthwhile thinking about what the boss wants, as opposed to what he asked for. And while doing that, you should be thinking about reuse and modularity. If your solution can be generalized, perhaps it can be reused in other situations.

And finally, you have to look at all the ways you could solve the problem, and come up with the quickest solution.

The Event

This event asks you to get a list of the 10 processes on a given machine, that are consuming the most memory. This raises two questions: “How do I get the processes?” and “How do I determine which property to use to ascertain memory use (because there are several)?” 

There are at least three ways to get a list of processes running on a given machine:

  • Use WMI: Use Get-WMIObject and specify the class Win32_process
  • Use native .NET: Use [System.Diagnostics.Process]::GetProcesses
  • Use a built-in cmdlet: Use the Get-Process cmdlet

All three of these mechanisms can be used to get all the processes. The objects returned by all three methods will enable you to sort by the memory used and then select the highest 10. So which is the best answer?

Developing the solution

You could use Get-WMIObject, but that might be more work (and as it turns out, the formatting would be more difficult, as I explain below). You could also use the GetProcesses() .NET Method, but that method does not provide an easy way to work against remote machines (the other two mechanisms provide a simple way to operate against any computer in your domain). But wherever possible, I tend to try to use the built-in cmdlets. Hence, I would choose to use Get-Process to get the processes.

Get-Process uses the ComputerName property to get the list of processes from a given machine (the default is the local host). Get-WmiObject also provides a ComputerName property, and it also provides a Credential property to enable you to use alternate credentials. If the environment includes computers in a different forest, or non-domain joined computers, you might be better off using Get-WMIObject to get the list of processes, but the directions did not give any clues about this point.

Another thing to note: The output that is specified in the Event details is very familiar. It’s the output generated by Get-Process. In this case, Windows PowerShell comes with some default display XML that formats the System.Diagnostics.Process objects into the nice eight-column format noted in the event instructions. You could use a set of hash tables plus a call to Format-Table to format the objects that are returned by the sorting the results returned from the Get-WMIObject cmdlet. Or you could use the default formatting that comes with Windows PowerShell.

So all things considered, I would use Get-Process to get the processes we need to examine. If the requirement changed, you might need to revisit this decision. For example, if the computers you want to examine are not in your domain, you may need to use WMI, or perhaps Windows PowerShell remoting, to get to the remote machines’ specific alternate credentials.

So if we use Get-Process to get the processes, how do we determine which processes are using the most memory? Windows has several memory counters that measure various aspects of memory usage (however, a complete discussion is beyond the scope of this blog). But in this case, your boss has decided he wants you to use WorkingSet as the counter. The working set value measures the amount of physical memory that a process is using.

Solution

So using all this, we can formulate a solution as follows:

Get-Process * | Sort-Object –Property WS –Descending | Select –First 10

This set of commands gets all the processes on your machine and sorts them by the WS (WorkingSet) property. Then we select the first ten (that is, those ten with the largest working set size). On my machine, this looks something like this:

Image of command output

This simple pipeline can be adjusted to point to a different computer by using the Computer property in with Get-Process, such as this:

Get-Process * -computer <computername> | Sort-Object –Property WS –Descending | Select –First 10

On my machine, this looks something like this:

Image of command output

Advanced solution

There is one further thing that you could do with this solution.  Given that there are two ways to get this list (local and remote), you could write a function like this:

Function Get-MemoryConsumingProcesses {
Param ($computer)
If ($computer) {
  Get-Process * -computer $computer | Sort-Object –Property WS –Descending |
     Select –First 10
} Else {
  Get-Process * | Sort-Object –Property WS –Descending | Select –First 10
}
}

The basic one-liner scripts (those with and without a Computer parameter) work just fine. But you might get an extra point if you modularized the solution as I showed here.

~Thomas

The 2012 Scripting Games Guest Commentator Week will continue tomorrow when we will present the scenario for Event 2.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 

Viewing all 3333 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>