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

 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



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 

Comments (33)

  1. mredwilson says:

    @Matt Tilford, I would handle it as adding a switch to a function (or to the script) One output displays the true / false if it is a laptop, and the other displays the two pieces of information called for in the scenario. This is why I did not show a picture because there are two ways to write this, or three ways if you count a combined scripted output.

  2. Anonymous says:

    For this event are Portables considered Laptops?

  3. Anonymous says:

    I too am a little confused @Jeff Wouters.

  4. mredwilson says:

    DavidW Laptops, portable PC's, Tablets, anything like that can be considered to be a "laptop" for this scenario.

  5. mredwilson says:

    @Brad do not appologize for being a noob — everyone was a noob at one time or other. I am glad you are using this time to learn PowerShell skills. So, a boolean value is True or False. On or Off. Exists or does not exist. Yes or No. Think like a light switch (not with a dimmer control) the lights are on or off. So here, returning a boolean would return a value that is TRUE if the computer is a laptop, or False if the computer is a desktop. Windows PowerShell has the $True and the $False automatic variables that correspond to Boolean values.

  6. mredwilson says:

    @Jeff Wouters This script does not need to do the actual count — it will provide the information you will use to make the count. I do not want to complicate your scripts by making you perform the actual remoting.  

  7. mredwilson says:

    @Michael Moore Yes, great point. This is a proof of concept, that will be part of a larger system. You do not need to do the count, and therefore do not need to run against remote systems. The main point here is figuring out HOW to actually get the information.

  8. SdeDot says:

    Good point Michael.  It would help if that was clariried.  I looked at this as we need to tally the number of laptop and desktop computers which would be a chellenge given we are not in a domain (not stated in the scenario or design).

    Also, the scenario or design does not state what OS these machines are running because some WMI properties are not available on Server 2003, XP, etc.

  9. Anonymous says:

    Question number 2: is it safe to asume that if a computer is not laptop then it is desktop or vice versa?  Am i asking that because of the function that needs to return a boolean value.

  10. mredwilson says:

    @Scott it is generally better that a function does not run itself.

  11. mredwilson says:

    @SdeDot NOW you are starting to get it! HOW can you reliably figure out if you have a laptop or a desktop computer!

  12. mredwilson says:

    @Pradeep Rawat your script does not need to actually run on remote systems.

  13. mredwilson says:

    @SoCalDavis yes … it is always a good idea to think about the script a bit before hitting submit. Just like in REAL life, it is always a good idea to think and to test a bit before hitting run for your script that runs on a production network.

  14. mredwilson says:

    @SteveH Virtual machines are not part of the scenario, but you could add that if you find it helpful.

  15. mredwilson says:

    @KFred yes a minitower is considered a desktop for this scenario.

  16. Anonymous says:

    How are we supposed to handle returning both a computer name as well as a boolean value. Are 2 lines of output acceptable as this is proof of concept?

  17. Anonymous says:

    I have my script ready to be submitted, but I think I will wait a bit. I hope someone can clear up the confusion (unless that's the point hehe). I'm keeping my fingers crossed for now.

  18. Jeff Wouters says:

    First "count the number of desktop computers and the number of laptop computers on the network" is stated and later "Your code only needs to run on a local computer."

    Perhaps something gets lost in the translation… but what is the goal here? Just one device or everything (remote?)?

    If all devices are the goal, then why the design point for only to run on the local computer?

  19. P-R says:

    I am bit confused too…..whether it needs to be run against remote computer(s) or as design point states only against local computer.

  20. Michael Moore says:

    Looks to me like the script only needs to determine is the system is a laptop or desktop on the local system, we're not being asked to display a count as part of the challenge.  So to me it looks like we would be designing a "Proof of concept" something that shows we can determine the type of system for a larger inventory report.

  21. brad says:

    sorry I'm a noob, what's a Boolean value

  22. KFred says:

    Is a mini Tower considered a desktop?   In our environment you either have a laptop or a desktop even if you can look at it and tell that it's a mini tower.

  23. DavidW says:

    For this scenario, should we consider only "laptops" as laptops and all others as desktops?

  24. Dawn Villejoin says:

    @Brad This link may be helpful concerning Boolean values…


  25. SteveH says:

    Should we handle Virtual Machines or disregard them?

  26. Scott says:

    Should the function run itself at the end of the script or is just having the function enough to satisfy the criteria?

  27. brad says:

    if were are look for laptop or desktop but the resualt is the be $true or $false.  how is this displayed? we have 3 different thing that we are looking at (desktop, laptop and others) does that mean you want an output like

    Desktop: true

    Laptop: false

    Other: fales

    or am I missing somthing

  28. Dawn Villejoin says:

    After now seeing all events, I have to say that this one has been the most fun! I really enjoyed it, and had a great experience throughout!! Thanks to Ed, all judges, and all sponsors for allowing this event to happen! Already can't wait for next year! 🙂

  29. Eleftheria Theologou says:

    Bit confused about which method to use! Been reading online and made me more confused!!! Since it it not mentioned we should consider that our script has to support operating systems like Windows XP etc?

  30. sweetball says:

    Thank You

    The given information is very effective.

    i will keep updated with the same.

    <a href ="http://www.sweetball.in/">industrial automation training  


  31. JoeTea says:

    With all due respect to the judges, it would be really good if the judges could mention the reason for which ratings are cut down please. Thanks

  32. Umair Mirza says:

    Desktop i would say. Probably a Dell inspiron. I was just reading its review at <a href="http://www.binary-store.com">Binary Store</a>

  33. Umair Mirza says:

    Sorry. looks like it doesn't support html.


Skip to main content