2012 Scripting Games Beginner Event 6: Compute Uptime for Local Computer
Summary: In Beginner Event 6, you are required to compute the uptime for the local computer.
About this event
Date of Event
4/9/2012 12:01 AM
4/16/2012 12:01 AM
You are the main network administrator for a small company. As such, your duties consist of a variety of functions, including assisting the Help Desk when they get behind. Recently, your manager has become concerned about server uptime. He wants you to write a script that will display how long a server has been “up.” He said that he is not concerned with anything fancy—he just wants a general idea. The only real guidance he provided for the task is, “Use WMI. There is a class called Win32_OperatingSystem that should do the trick for you. Tell me the server name, and how many days, hours, and minutes the server has been up.”
The output that is shown in the image that follows meets the boss’s requirements.
- Your solution only needs to run locally.
- Your script should be easy to read and easy to understand.
- Your script is only concerned with the uptime for the local server, calculated with the current time. Do not worry about time zones or about comparing up times with different computers.
- Pay attention to the formatting of the output and the script itself.
2012 Scripting Games links
I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at firstname.lastname@example.org, 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