Windows PowerShell for Vista IntroductionWindows PowerShell for Vista IntroductionMy mission is to help install Microsoft's PowerShell on Vista. Once you have installed PowerShell, the first task is to set the script execution policy:
Introduction to Windows PowerShell Topics
7 Things to get you started with PowerShell
How to Launch PowerShell in Vista
Feel the control and agility of PowerShellIn this section of my website I am going to focus on getting you started with Microsoft's PowerShell. Before I give you more examples, I want to say to developers and programmers that PowerShell has all the control and agility of languages such as perl, ruby and python. One clue of PowerShell's object nature is that you first need to install .NET Framework 2.0, otherwise PowerShell cannot work. Above all else, PowerShell gives administrators the power and versatility of the UNIX Bash command line. My most difficult concept to convey is an act of faith. Trust me that PowerShell will deliver the goods and exceed your expectations. Here is an example of what PowerShell could do; imagine this scenario: 'One of my servers is running slower than the rest, can I check the version numbers of all the processes?'. You are unlikely to find a built-in tool to answer this question, however, if you are expert in PowerShell you will be able to build cmdlets to answer this and similar operating system questions. Programmers and developers will soon create scripts or cmdlets, yet my task is to persuade those with just server administration skills that they too can create code to interrogate the operating system. Naturally, Admins will use the time-honoured tradition of copying other people's scripts, indeed one of my goals is to create a bank of such cmdlets. My greatest challenge is to provide a middle way, to persuade Admins that they can decipher the commands and easily modify the code to suit their own situations. My Challenge - To get you started.My goal is to get you started with PowerShell. My challenge is that in thirty minutes you will be able to perform all tasks that you currently achieve at the CMD prompt, and start issuing new PowerShell commands that are just not possible with CMD.EXE. Assumption, you have successfully installed PowerShell and .NET Framework 2.0. Begin by clicking Start, Run and type powershell, alternatively, create a short cut to powershell in the Quick Launch area. Try out a few PowerShell commandsNormally, when people move to another scripting language their old trusty commands don't work in the new shell. Well, if you migrate from cmd.exe to PowerShell, then cd and dir are available thanks to Aliases. In a short time, you adapt to the new ways of doing the same things. For example, set-location is the equivalent of cd, and get-Childitem the Alias for dir. In addition, PowerShell allows you to run all the native Windows executables such as Ipconfig, Tracert and NetDiag. The miracle of PowerShell is that thanks to Aliases, those coming from UNIX, perl or .NET can make a similar transition but employing their much more high powered commands. Principle 1: The heart of PowerShell is always a verb-noun pair. You start with verb add a hyphen then finish with a noun. For example, set-location is the equivalent to cd (change direcory) in DOS. Incidentally, the reason cd works in PowerShell is because it has a built in Alias called cd which maps to set-location. Good news, you can create your own aliases. PowerShell Introduction - Simple Examples I realize that these are Windows rather than Exchange 2007
examples but I want to get you
up and running: get-Process Principle 2: Create lots of scripts or cmdlets. Save your text commands in a text file with a .ps1 extension, for example ProcessAll.ps1. Moreover, save that file into PowerShell's working directory. Then execute these cmdlets from within the Microsoft Shell, for example: .\ProcessAll. Your two key characters are the dot and the backslash. The secret is get into the rhythm: dot, backslash then filename. There is no need to add the .ps1 extension, also avoid spaces. If all else fails just type the complete path:
Auto-completion examples Example of a PowerShell Cmdlet # This cmdlet generates a report about memory in active processes
HelpPowerShell's help is clear, concise and full of useful examples. Put your faith in PowerShell's help. Cast aside negative experiences of other help files. Overcome your pride and ask for help. All you need to query the vast help information store, is either precede the item with 'help', for example, help get-Member; or else append -? for example, get-Process -? (hyphen question mark). The executable powershell.exe even has its own help, at the PS prompt, type: powershell -? Another useful sister cmdlet is:
get-command, which lists the built-in cmdlets. Better still, try the * wildcard: Who is Windows PowerShell designed for?What impresses me about PowerShell is that even as an amateur, I can get going and create interesting scripts with ease. The hidden message is that PowerShell works at many levels, moreover, you can easily rise through the levels. In addition PowerShell teaches you about scripting theory, and scripting theory teaches you what to look for in PowerShell. The vision of PowerShell is to provide cmdlets (scripts) which automate repetitive tasks. There is a feeling, at least in Exchange 2003, that people cannot find settings because they are hidden underneath so many levels of sub-menus. What I find is that with both Exchange and WMI cmdlets it soon becomes as fast to issue a few commands in the Microsoft Shell, as to configure the same settings through a GUI. Admins who want a command line shell for interactive scripting will enjoy PowerShell. The most amazing feature of PowerShell is that it lets you think in previous language, while you figure out its native ways of operating. Creating new Aliases or using the built-in Aliases is the key to this transition.
˚
PowerShell OverviewThe secret of PowerShell is to put commands in a file (cmdlet) and then forget them until the next time you need their automation. With PowerShell you can manipulate text objects in an advanced manner. You also get access to data stores which can be accessed as namespaces, for example, WMI and the Registry. Consistency is a watchword, learn a verb in one area, then apply it to other PowerShell objects. For example, once we learn the verb 'Stop', there will never be a need to deviate, we don't suddenly change to 'kill' or 'terminate' PowerShell supports COM, WMI, ADSI .NET XML. Also unified tools from C++ C# and perl. Naturally it supports Sub Routines, Constraints and utilities, for example: foreach, group, select, sort and where. It is claimed that MMC v 3 and the Exchange 12 System Manager will have the ability to auto-generate PowerShell scripts. The catch phrase is: 'Figure out, then manipulate'. After I got PowerShell installed and when I had mastered a few simple commands, I listened to two 90 minute Microsoft Webcasts of PowerShell. If I had listened to the presentation first, I would not have gone any further, I would have thought, 'PowerShell is too difficult for non-programmers like you Guy'. So my message is suck it and see, just try some of my examples, you will be amazed how easy it is get going with PowerShell. However, there was a very important hidden message in that presentation, it was saying to me, 'This is a seriously powerful scripting language'. The speaker explained how PowerShell could do stuff that people now do in UNIX, perl, C++ or Visual Basic. One day I will return that presentation because there is so much for me to learn about scripting principles in general and objects in particular. Summary of PowerShell IntroductionWith Microsoft's PowerShell the underlying philosophy is to provide powerful scripts to automate occasional tasks. Furthermore, PowerShell is designed to make it easy for people to transition from other languages. Trust me, it really is easy to get started with PowerShell commands. See also these PowerShell tutorials• PowerShell Home • Introduction • Dreams • 3 Key Commands • Cmdlet scripts • Real life tasks 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.
*
|
||||||