Guy's Scripting Ezine 109 - Getting Started with PowerShell (Monad)Guy's Scripting Ezine 109 - Getting Started with PowerShell (Monad)
♣ This Week's SecretShortly after I wrote this article, Microsoft announced a name change: Monad will now be called PowerShell. Monad (PowerShell) is my sort of scripting program. It is easy to get started easily, yet there is plenty of power and depth. Above all, Monad is the way of the future, at the very least it will replace CMD, at the very most; Monad will give you new control over your server from the command line. This Week's MissionThis week I want to persuade you to try Monad. My mission is to convince you that there are benefits here-and-now for configuring your server by employing PowerShell. Let us put aside the hype and forget about the future, just start today using Monad to interrogate the Processes, Services and Eventlogs. So, put aside the GUIs and CMD, and experiment with PowerShell (Microsoft's Scripting Shell). Once we have mastered Processes, Services and Eventlogs, which is no more that 20 minutes work, we will turn our attention to PowerShell with WMI*. It is by choosing Monad instead of VBScript to querying WMI, where you will reap the greatest benefits in the spring of 2006. In the future, you may well employ Monad to configure Exchange 12 or one day for Longhorn, but here and now, Monad will help you manage your Windows 200x Servers. (* PowerShell and WMI will be featured in Ezine 110 next week) If you are looking for handy network utilities, try some of the free downloads at Tools4Ever Getting Started - PreliminaryI assume that you have downloaded and installed both .NET Framework 2 and Msh_Setup.msi. You can then launch Monad by clicking on the Start menu, Run and type 'MSH' in the dialog box. Incidentally don't worry about tiny Beta errors such as 'Cannot find the P:\ drive'. As a base line, think of PS as the Microsoft's new Scripting Shell which replaces cmd. The power of PowerShell comes from the verb-noun pairs which interrogate the operating system. My friend and Unix expert 'Barking' Eddie says MSH is like UNIX's bash. Eddie also told me how Monad reminded him of an affair involving Ruby, Perl and a strange Python, but I will save that story for another day. Next, I have three examples for you to see for yourself the abilities of PowerShell: Get-process, Get-service and Get-eventlog. Get-processAt the MSH prompt type: get-process Learning Points The heart of PowerShell are verb-noun pairs. Note and applaud Microsoft's consistency, the nouns are always singular: process, service and never: processes or services. Professors of PowerShell claim they only need to learn 50 verbs to master PowerShell, so far I have only needed 20 verbs. My point is it's easy to get started with PowerShell. Get-memberGet-member is all you need to research your object or nouns. For example: The only trick to this double statement is typing the correct pipe symbol. You need ASCII 124 or this symbol: | I hit the key next to the z on my keyboard, but the position may vary. I don't want to make a mountain out of a molehill, but ASCII 124 displays as a | in most programs, but this pipe character displays as ¦ in the MSH shell. To test the character, hold down the Alt key and on the numeric keypad type: 124. One result of issuing the command: get-process | get-member, is that amongst the properties you see 'company'. Finding company links to one of my most important messages with
PowerShell,
namely that you can do stuff in MSH that you cannot do with either the Task Manager or the CMD prompt. To see what I mean try this: If you wish, you could append the old dos: | more, The property 'Company' and the verbs 'sort-object' and '-groupby' are useful and flashy for a demonstrations, but the real message is that PowerShell had loads of gears and extra dimensions. My thesis is this: professional developers and programs can produce some stunning scripts or cmdlets. Moreover, we ordinary mortals can dissect, amend and then use the commands to investigate our own servers. On this score, my mission is to collect PowerShell one-liners, two-liners, short cmdlets and publish them on my website. It would be my pleasure to credit you if you send in such a cmdlet. No script is too short, if it's cool and different from what's on my site already I will be delighted to receive your verb-noun | couplets. Guy Recommends:
The Free IP Address Tracker (IPAT)
| |||||
Custom Search
|
Guy Recommends: WMI Monitor and It's Free!
|
|
Home Copyright © 1999-2012 Computer Performance LTD All rights reserved Please report a broken link, or an error. | |