2012 Scripting Games Advanced Event 9: Perform an Inventory

2012 Scripting Games Advanced Event 9: Perform an Inventory

  • Comments 11
  • Likes

 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 

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment
  • Hi Ed,

    that seems to be a quite manageable task!

    BUT a task for hard working people .... 12 properties! Whhhooooo !!!

    And "the most logical units" are back!

    The design points are usually the important point providers, so I have to ask,

    if I read:

    ".... it does not need the ability to run against remote computers"

    does it imply:

    "... but you'll get an extra point, if it does"

    Klaus.

  • Do we assume all computers are Vista and above?

  • @K_Schulte This particular scenario maps out how you can obtain all 5 points. 2 points for getting the basic properties. 1 point for xml, 1 point for creating the file in a specific location, 1 point for creating a specific type of name. 1 point for error handling.

  • @Jason W. I did not specify in the scenario. You may want to mention that in your organization all your computers are VISTA or above ... Make it clear in your comments to your script. BE SURE TO PUT IT IN YOUR COMMENTS or one of the judges might say, "well this code does not work on Windows XP" and might deduct a point.

    It is like real life ... If I write a script that only works on Windows 7, I make a comment AT LEAST. A better way to do this is to check the Operating system version, and display a message that the script ONLY works on Windows 7 or above. This is pretty easy to do by checking the OS version number, and making sure it is at least that number prior to running.

  • Hi Ed. Have a question for you:

    "MAC address of the primary network interface". You mean primary adapter - adapter who have IP address?

  • @Roman Prosvetov Because this is running locally, it might be possible that at the time the script runs, the primary network adapter might not have an ip address. I think it might be a good idea to do the following: IF a network adapter has an IP address it should be reported (of course several of my servers have multiple network cards that are on different networks and therefore have multiple IP addresses, so you should report all network cards that have IP addresses. But if the machine has NO IP address on any of the NIC's you should report them, as well, and indicate that it does not have an IP address.

  • @Ed:

    *LOL* If I add up your potential points, I can't help wondering .... *ssss*

    "@

    @K_Schulte This particular scenario maps out how you can obtain

    all 5 points. 2 points for getting the basic properties. 1 point

    for xml, 1 point for creating the file in a specific location,

    1 point for creating a specific type of name. 1 point for error

    handling.

    @" -match '(?m)(?<total>\d)[\D]+(?<first>\d)[\D]+' + `

             '(?<second>\d)[\D]+(?<third>\d)[\D]+' + `

             '(?<fourth>\d)[\D]+(?<fifth>\d)' | out-null

    "Ed's statement is {0}" -f `

       $([int]$matches.total -eq [int]$matches.first+$matches.second+ `

                                 $matches.third+$matches.fourth+$matches.fifth)

    Klaus.

  • By "Operating System Version" do you mean the ugly version number or the more happy "Windows Server 2008 Enterprise"?

  • @Scott Heath either one you want to report.

  • Hi Ed, a bit late here, but do you want the DNS domain name, or the netbios domain name? I assume the former?

  • @Alex, DNS domain name