2012 Scripting Games Advanced Event 2: Find Information about Remote and Local Services

2012 Scripting Games Advanced Event 2: Find Information about Remote and Local Services

  • Comments 26
  • Likes

 2012 Scripting Games badge

Summary: In Advanced Event 2, you must find information about remote and local services.

About this event

Division

Advanced

Date of Event

4/3/2012 12:01 AM

Due Date

4/10/2012 12:01 AM

Event scenario

You are a server administrator for a medium-sized enterprise company. Your boss has tasked you with finding the way that all services on all servers start. You need to present your findings in a spreadsheet that includes the following information:

  • The server name
  • The service name
  • The start mode of the service
  • The user account used to start the service
  • The current status of the service

An acceptable output for this task is shown in the following image.

Image of command output

Design points

  • You should use the easiest method possible to display the information in a spreadsheet.
  • You must include the ability to run the script both on a local computer and on a remote computer.
  • You must include the ability to run the script with alternate credentials when operating against a remote computer—you should impersonate the logged on user when running locally.
  • You do not need to add comment-based Help for this scenario, but additional points are awarded if you do include appropriate comment-based Help, such as a description, examples, and parameters.
  • If the script requires administrative rights to run, you should check to ensure that the script is running with admin rights. If those rights are not present, you should display an appropriate message and exit.
  • For the purpose of THIS exercise, do not write a module. You should make your script stand completely alone, with NO external dependencies. Therefore, EVERYTHING this script needs should be put in this script. Failure to do so 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 

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,

    this looks ( at least on first sight :-) like a managable task!

    What should be done, is definitely clearer than the first event, if I got it right ...

    Anyway: A question I got on mind is: "May we rely on Excel being normally installed on the local machine where the report should be displayed?"

    btw: "Is it Ok to assume, the data is consumed by Excel at all?"

    Klaus.

  • re point: "If the script requires administrative rights to run..."

    Is this something we need to determine and only add code if necessary?

  • Bit stuck on this one. There are a few ways that the account could have administrator rights, or in this scenario would the account be a member of the local administrators group?  Also, "Your boss has tasked you with finding the way that all services on all servers start", does this mean an input file of server names is required or should the script discover server objects in AD?  Or is it up to us? :)

    Thanks!

  • @K_Schulte yes, it is a managable task :-) Yes, you can rely upon Excel being installed on the local computer where the report will be displayed. The picture above, shows a spreadsheet, and states that the output is acceptible. So it is safe to assume that the data is able to be displayed by Excel.

  • @Ken Hamilton Yes, you should determine if your script requires admin rights to retreive all the service information specified by the scenario on both a local and on a remote computer. If this task requires admin rights, then you should add the code to detect if the script possesses such rights while it is running. If the script does not have admin rights, then you should display a message and exit the script.

  • @Matt Hitchcock Yes, it is true that there are different ways the script could be running and have admin rights ... your task is to determine if the script has the rights it requires to successfully complete PRIOR to running the script and having it fail. If your script requires specific rights to run (either locally or remotely) then you must see if the script has those rights prior to execution of the script, and gracefully exit before displaying a bunch of access denied errors. The boss did not specify HOW you are to determine that you are querying all of your servers. Therefore it is up to you, you can read a text file, query AD, query a SQL Database, provide an prompt and type the server names in, whatever is appropriate for you. But keep in mind, that your script also must have NO external dependencies, and that judges will be running your script for score ... (the judges might not have Active Directory installed on their network, or they might not have a SQL database on their laptop) ...

  • Time to look at last year's submissions for 'comment-based help' help and another small novel for the notes section of it.  If my thinking doesn't get fixed then my scripts will never get fixed.

  • @Chris Seiter Take a look at my Hey Scripting Guy blog posts. I have numerous posts about comment based help. In fact, I have a function in my ISE Profile that automatically adds help to a script. blogs.technet.com/.../searchresults.aspx

  • Hi Ed,

    May we assume that PowerShell remoting is enabled?

  • @Alex McFarland yes, you can assume that PowerShell Remoting is enabled.

  • Would making the assumption that DNS or WINS is running within the environment count as an external dependency?

  • @Jeff Schulman I think that it is save to assume that name resolution works. If you are concerned, you can always use test-connection to ensure that you can connect prior to doing the "work" of the script.

  • When I browse 2012sg.poshcode.org/.../TopUsers, how is it that some people have 4 and 5 scripts rated already, even though only two events have been released so far?

  • @Ryan Ries ... no idea. I did not know this page was live yet. I will ask Joel.

  • Hi there,

    The question about remoting led me to another question: can we assume that any / all firewall ports to remote machines are open, or could there be restrictions there?

    Thanks!