Ezine 166 - Learning PowerShellEzine 166 - Learning PowerShellThis ezine is dedicated to persuading people to try PowerShell. I am not selling anything! You need no money, just the inertia to download the free PowerShell files from Microsoft's site; then try a few of my basic ideas and examples. Topics for PowerShell in Exchange 2007
This Week's SecretDon't believe that PowerShell is just for Exchange administrators, nor is it just for running 'DIR' commands. Equally, don't think - 'Those process commands are flashy, but are nothing like the real world'. I say again, PowerShell is the way of the future, you are limited only by your own imagination, it's the sort of language to dip in to as and when you need a solution to a computer configuration or interrogation problem. If you have already started learning PowerShell, be patient with me, this week I want to tempt more people into the community. Just as anyone can hit a tennis ball with that big racket, so anyone can type a PowerShell command. Just as only one in a million are good enough to play tennis at Wimbledon, so few are good enough at PowerShell to become gurus. My point is PowerShell is easy to learn the basic strokes and enjoy the game, yet it has all the intricacies you would expect from a top notch game - sorry, I mean script language. Who Will Benefit From PowerShell?I have an overwhelming sense that PowerShell is the future way to configure at least some of your computer settings. At the very least I am sure that PowerShell will replace the aging 'DOS' shell. In my minds eye I see at least three distinct groups of PowerShell learners who will benefit from this scripting language. 1) Whenever configuring a setting via the command-line is faster than the GUI, then people will always be attracted to the language. Exchange Administrators have good reason to learn the rudiments of PowerShell syntax, in particular the -parameter to modify the main verb-Noun cmdlet. Even if you have no desire to use Exchange 2007, this concept of administrators configuring items by typing instead of clicking the mouse will spill over into Windows Server 2008 and its successors. 2) People will transfer from VBScript to PowerShell, particularly if they want better control over WMI. (Windows Management Instrumentation). The biggest benefit is efficiency; PowerShell constructions are shorter and less fussy than the equivalent VBScript commands. 3) As an 'old timer', I must also take into consideration those just starting out in
computing. Newbies have the advantage of no baggage from DOS or other
ancient systems, consequently they will probably learn PowerShell faster than
any of us. One of the best ways to practice with PowerShell is to get
basic information about a) files, b) services, or c) processes. For
example try these three commands: ?) Budding programmers who want to develop applets using PowerShell. This is an area where I confess to being a bit of a dreamer. More so as my website is geared to the generalist, rather than the professional programmer. Nevertheless, I want to plant the idea for prospective script writers to choose PowerShell as a vehicle for writing their programs. My dream is that eventually such script writers will do us all a favour by producing nifty applets. ˆ PowerShell's PatternsThe first pattern to observe is that each PowerShell cmdlet starts with a doing word like, 'get', 'set', or 'start'; this verb is followed by an object, like 'service', 'process', or a myriad of other operating system handles with strange names. The result is a basic cmdlet, for example, get-process, or start-service alerter. Incidentally, top programmers use only about ten of these verbs, however, they have a huge bank of nouns. The second pattern to research is the -parameter. Once you have a cmdlet pair the trick is to gain precise control by appending a modifier or -parameter. For example, -name, -path or -recurse. Here is an example which lists all the files under the system32 folder: get-childitem -path c:\windows\system32\ -recurse (Recurse means drill down through the sub-directories). The third pattern to master is PowerShell's signature tune - the pipe symbol (|). This tiny symbol means make the output of the first section | the input of the second section. For example, list files | send the list to this file: get-childitem -path c:\windows\ | out-file c:\windows.txt Note 1: Look in the c:\ root directory for a file called windows.txt Note 2: You could change the path to: -path c:\windows\system32\ -recurse PowerShell Strategies and ScenariosIt would make my day if you experiment by using PowerShell for as many different types of task as possible. But don't follow me slavishly; develop your own PowerShell agenda. Here are ideas of how to employ PowerShell:
Installing PowerShellYour strategy for installing PowerShell varies depending on your underlying operating system. Much of the of PowerShell's richness comes from .Net framework, thus its no surprise that installing .Net framework is a pre-requisite to installing PowerShell. However, watch out for version conflicts if you add .Net Framework, 2.0 or 3.0 when you already have applications using version 1.1.
As of June 2008, the current version is PowerShell 1.0. While there is a CPT v 2.0 (Community Technology Preview) under development, Guy says stick with the tried-and-tested version 1.0 until a fully functional version of 2.0 is released. While learning you want success, and that means a solid foundation with no flaky new features. The main advantage of version 2.0 will be remote scripting, but that's not a feature you need at the very start of your PowerShell career. Go to Microsoft's Download Site More Resources for PowerShellA sign that PowerShell is growing in popularity in the number of books, forums and add-ons that enthusiasts have developed. While I have bought two books, I cannot recommend either. My message is no book can cover all of PowerShell, thus make sure that any book you buy covers the sections that you are interested in. Forums:
Microsoft's script center, Microsoft's PowerShell Documentation Pack. Add-ons Quest: QAD. 537 If you are looking for handy network utilities, try some of the free downloads at Tools4Ever Summary of Learning PowerShellPowerShell is one of those notions where you have to believe before you can see. Believe PowerShell is the way of the future and you will see opportunities every time you sit down at your computer. See more Microsoft PowerShell tutorials• PShell Home • Introduction • Dreams • 3 Key Commands • Cmdlet scripts • Real life tasks • Remote PowerShell • -Online • WinRm and WSMan • Invoke-Command • Jobs -asJob Please write in if you see errors of any kind. Please report any factual mistakes, grammatical errors or broken links, I will be happy to not only to correct the fault, but also to give you credit.
*
|
||||||