Learn about Windows PowerShell
The 2011 Scripting Games will be held April 4–April 15, 2011, and will test a variety of commonly required skills for IT pros seeking to automate their production environment. The development of competencies in the areas shown below will help the prospective Games participant to successfully complete the 10 task-based scenarios that make up the 2011 Scripting Games.
More important than competing in an online competition and receiving a certificate (suitable for framing) is the usefulness of the skills represented. These fundamental skills routinely come into play when IT automation is required. Familiarity with these skills will help you become a better Windows PowerShell scripter. In this manner, the 2011 Scripting Games Study Guide is an essential resource to learn Windows PowerShell, whether or not you are competing in the 2011 Scripting Games. (In addition to the resources highlighted here, make sure you also consult the 2010 Scripting Games Study Guide.)
Working with processes is a fundamental skill for nearly anyone who logs on to a Windows computer. Memory management, performance management, and security management often come down to process management. In Windows PowerShell, it is very easy to work with processes to see which resources they are consuming, and to start and stop processes. I have written quite a bit about working with processes from within Windows PowerShell; these articles provide an overview of the breadth of things that can be accomplished using Windows PowerShell. (By adding the Getting Started tag to the view of the articles on the Hey, Scripting Guy! Blog, the more fundamental articles are filtered.) If you are just learning Windows PowerShell, see the Scripting Wife article where she learns how to start and stop processes. It is both fun and informative. You may also wish to review some of the Windows PowerShell scripts in the Scripting Guys Script Repository that deal with processes.
If it is important to work with processes, it is doubly important to understand what services are doing on your machine. One reason for this is that while processes show up readily in Task Manager, services have a tendency to hide. I do not mean to impart nefarious intent to them. It is just the way they group in the services host processes that makes them hard to keep track of. Starting, stopping, examining the start order, changing the service account, examining the service host process, examining service dependencies, and changing the recovery procedure are all common service-related procedures. I have written more than a dozen Hey, Scripting Guy! Blog posts that detail working with services. Some excellent scripts in the Scripting Guys Script Repository illustrate working with services. They are worth careful examination.
Sooner or later, everyone needs to work with files. Even though most user documentation is held in Microsoft Word and Microsoft Excel files, people who are IT pros often work with plain text files, comma separated value (CSV) files, and occasionally tab separated value (TSV) files. The tasks include reading data in from the file, writing data to the file, and creating and deleting the files. I have written a number of Hey, Scripting Guy! Blog posts about files in general (using the “Windows PowerShell” and “files” tags reveals nearly 40 articles). A good overview of the process is the How Can I Work with Directories, Files, and Folders by Using Windows PowerShell? The “Windows PowerShell” and “text files” tags reveal around 30 articles that specifically have to do with working with text files by doing things such as updating text, searching for text, and the like. Because this is a fundamental skill, this task has occurred in recent Scripting Games, and the solutions to those events provide extremely valuable information while highlighting come rather clever tips and tricks for working with files. From a beginner’s perspective, see The Scripting Wife Redirects Output and Creates a Text File. You also may wish to see some scripts from the Scripting Guys Script Repository that illustrate working with text. In addition, you may wish to look at some scripts that illustrate working with files from a Windows PowerShell script.
If it is fundamental to work with files, it follows that working with folders is also a fundamental skill. In addition to creating and deleting folders, knowing things such as the amount of disk space consumed by folders is essential. No matter how big hard disk drives grow, there is always some application that will grow to consume the available disk space. Put another way is the second law of computing: “The user’s demand for disk space will always grow to equal the amount of available disk space plus 10 percent.” Details for creating folders, moving files to folders, and deleting folders appear in this series of Hey, Scripting Guy! Blog posts (the tags are “Windows PowerShell” and “folders”). The Scripting Wife learns about working with special folders in this Scripting Wife article, and her experiences are especially valuable for beginning scripters. There are some really clever scripts in the Scripting Guys Script Repository that illustrate some of the techniques involved in working with folders from a Windows PowerShell script. They are worth a careful reading.
While it is true that many scripts only need to display information in the Windows PowerShell console, it is also true that many times that output needs to go somewhere else. Whether that output is to the console as a table or list, or written to file, sent via email, written to a CSV file, database, Word document, Excel spreadsheet, Visio application, PowerPoint presentation, or sent to a printer, you must deal with output and make the appropriate decisions concerning its use and application. I have written nearly 20 blog posts that talk about displaying output (the tags are “Windows PowerShell” and “displaying output”). These articles cover the gamut from changing the title bar on the Windows PowerShell console to drawing a cat on a fence. Some excellent scripts in the Scripting Guys Script Repository illustrate displaying output. You should review them in your preparation for the 2011 Scripting Games. Wink nudge.
Like it or not, IT pros need to know and understand how to work with Extensible Markup Language (XML). Conceptually, XML is not all that complicated, but the problem for IT pros has always been the lack of good tools to simplify working with the stuff. Developer types have the power and the flexibility of Visual Studio, but IT pros did not have anything until Windows PowerShell. There is XML Notepad, but it is not really aimed at IT pros. However, XML is way more flexible than a simple CSV file in its ability to store structured data, and as the basic tool set in Windows grows increasingly powerful, IT pros will continue to bump into XML. Therefore, now is a great time to begin to look at this stuff, and to get comfortable with parsing it. I have written several blog posts about working with XML from inside Windows PowerShell, and I have also had several great guest bloggers who have dealt with the topic of XML and IT pros. From a beginner’s perspective, my post called Is There an Easier Way to Work with XML Files? is a great place to start. One reason it is important to learn about Windows PowerShell and XML is because XML data is often returned from web services. Accessing web services from a Windows PowerShell script is cool because you can easily look up weather for a specific city, or check stock prices from a script.
Because Windows PowerShell is reliant on the .NET Framework, it is really easy to develop Windows PowerShell scripts that connect to the Internet and accomplish useful tasks. Whether it is using Windows PowerShell to download files from a particular website, or to submit a search string to the Bing web service, the number of tasks that involve connecting to the Internet continues to grow every year. There have been several Hey, Scripting Guy! Blog posts that talk about working with the Internet from inside Windows PowerShell.
It was possible to use regular expressions from VBScript. That was something that used to amaze people when I was teaching my VBScript classes years ago. Of course, the regexp object in VBScript was a bit cumbersome and had some of its own quirks, but it was a useful technique. So what is the big deal with regular expressions in Windows PowerShell? Well, for one thing, regular expressions in Windows PowerShell bring complete support for the language. In Windows PowerShell, we now have the same support for regular expressions that the .NET Framework provides. I can work with regular expressions in a C# application in the same manner as I can within a Windows PowerShell script—that is not only way cool, but also extremely powerful. I have written more than a dozen Hey, Scripting Guy! Blog posts that detail working with regular expressions to accomplish some very useful tasks such as parsing telephone directory listings. In fact, the telephone listing article is a great overview of the steps involved in working with regular expressions in Windows PowerShell. Other articles from Regular Expression Week on the Script Center include converting a tab-delimited file into a comma-separated value file, parsing a firewall log for dropped packets, and parsing a firewall log for sent packets. Taken together, these four articles combine to create a great short course in working with regular expressions from within Windows PowerShell.
One last thing an IT pro needs to know how to do is to work with local user accounts and groups. In fact, now that we are using Windows NT–based machines at home instead of Windows 9.x machines, even my dear old mom needs to know about local user accounts and groups. (In particular, I need to know that she is not a member of the local administrators group.) This is the point for people using computers at home; they should not be running the computer with a user that is a member of the local administrators group (the principle of least privilege). This is because it is too easy to hose things if one is running with too much power. I have written nearly a dozen blog posts that talk about working with local user accounts and groups. The tasks covered include creating groups, creating user accounts, changing passwords and other related operations.
I would love 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. See you tomorrow. Until then, peace.
Ed Wilson, Microsoft Scripting Guy
hello....is this game competation is for students also??
I want to join it n I m a engginearing 3rd yr student.
Hi Ed, where can we register for the games???
@MAYURI students are definately encouraged to participate in the Scripting Games. It should be a great learning experience for you.
I will have registration information listed soon. We are setting up the site, and need to test it out. Registration will be fast and easy. Stay tuned for details.
Thanks for the resource! I wanted to update any other readers who happened upon this article since the links have changed. The "these articles provide an overview of the breadth of things" link should point to:http://blogs.technet.com/b/heyscriptingguy/archive/tags/processes/