Ezine 215 – Learning PowerShell

Leaning PowerShell’s v 2.0

For the next 6 weeks I want to encourage readers to learn PowerShell.  If you take up my challenge to learn PowerShell it will make your Windows administrative tasks easier and more fun, furthermore, at the end of the course I will provide a PDF of this mini-series of ezines.


The Benefits of PowerShell

Do you find that there are too many Windows menus to remember?  Are you fed up with long drill-downs before you locate the right setting?  If so, you may be interested in finding out how to type half a dozen PowerShell commands so that you can get just the information you need quickly.

Perhaps you discovered by accident that certain operating system changes are only possible if you use PowerShell commands.  There are number of Exchange administration tasks where Microsoft doesn’t provide a GUI, consequently, the only way to configure the setting is by running the PowerShell command specified in a Microsoft knowledge base article.  Working with these cmdlets may make you curious to see how else you can use PowerShell.

Maybe the truth is that secretly you have always wanted to learn a scripting language.  If so, then I suggest that PowerShell is better choice for a Windows administrator than VBScript or C++.  One line of PowerShell can replace 10 lines of VBScript, especially when you are coding WMI modules.  With C++ it may take a month of studying before you can write useful code, whereas you can be productive in PowerShell in just one afternoon.

Installing PowerShell v 2.0

I am sure that it’s frustration with installing that causes most of my new PowerShell recruits to give up.  However, if you focus on just this one decision, then your install will be as straightforward as any Microsoft product.  Ask this question:

Do I need to ‘Turn Windows feature on’, or do I need to download PowerShell and .Net framework files from Microsoft’s Site?

In Windows 7 PowerShell is already installed as part of the operating system.  If you are running Windows Server 2008 R2 then you just navigate to the Control Panel, Programs and ‘Turn Windows feature on’, scroll down to the ‘W’ for Windows PowerShell and check that box.  For operating systems that pre-date PowerShell such as Vista, or Windows 2003 then you have to install PowerShell and .Net Framework files, which you can get from Microsoft’s own site.

Your First Steps in PowerShell

My mission is to get you started.  Just humor me, and apply my simple method of running a few commands, don’t try installing PowerShell 2.0’s remoting before you have mastered what you can do on the local machine.  My point is that PowerShell remoting is really fiddly to setup, especially for a beginner.

Begin by clicking on the Start Orb / Button; then search for PowerShell and then right-click the Windows PowerShell ISE version.  Suggestion: before you launch PowerShell pin it to the taskbar, start menu, or create a shortcut.  The benefit of the ISE (Integrating Scripting Engine) version is that you get a GUI.  ISE is new in PowerShell v 2.0, its color-coding helps to identify typos, and it’s much easier to amend and run commands than the plain command line version of Windows PowerShell.

The situation: PowerShell ISE launches, what do you do?  Try this command:



Status Name DisplayName
—— —- ———–
Stopped AeLookupSvc Application Experience
Running AppHostSvc Application Host Helper Service
Stopped AppIDSvc Application Identity
Running Appinfo Application Information
Stopped AppMgmt Application Management
Stopped aspnet_state ASP.NET State Service
Running AudioSrv Windows Audio
Running BFE Base Filtering Engine
Running BITS Background Intelligent Transfer Ser…

Learning Points

Note:  PowerShell becomes easy once you realize that at the heart of each cmdlet pair is a verb such as ‘Get’ followed by a noun such as Process, Service or ChildItem.  Sister commands to Get-Process include Stop-Process, then there are cousins such as Start-Service or even Restart-Service.

Guy Recommends: WMI Monitor and It’s Free!Solarwinds Free WMI Monitor

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft’s operating systems.  Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your scripts.

Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory or Exchange Server. Give this WMI monitor a try – it’s free.

Download your free copy of WMI Monitor

What Next?  Research How To Learn!

The appeal of PowerShell is that it’s so easy to get started.  In fact PowerShell’s biggest contradiction is that even those who have zilch programming experience can instantly retrieve information about the operating system, while at the other side of this contradiction is that you can do more stuff in PowerShell than you can do in VBScript or JScript.  PowerShell really is all things to all people.

My point is that you can begin by typing two word cmdlets, such as Get-Process, and then it’s just a question of how much you want to learn about scripting techniques such as looping and building functions.  Furthermore, PowerShell is ideal for those who like creating snippets of code, then bolting them together using PowerShell’s signature tune the Pipeline (|), for example here are three simple units joined by two (|):

 Get-Process | Format-Table Name, WorkingSet | Out-Printer

Research more cmdlets

Get-Command -verb get

Result: Lots of new PowerShell commands to try.

Challenge: Try each of these commands in turn.

  • Get-Process
  • Get-ChildItem
  • Get-Eventlog -list

PowerShell’s Golden Rules

PowerShell mimics what you can do in a GUI.  The benefit is that you can issue commands quicker and with greater precision than you can clicking through Windows menus.

  • The basic unit is always the verb-noun cmdlet.
  • PowerShell’s signature tune is | or the pipeline.  The concept is that the output of the first command becomes then input of the second or third pipeline.
  • Employ Get-Member to research methods and properties which you can refine with pipelining.

Get-Service | Get-Member

Here is the benefit of knowing a cmdlet’s properties so that you can refine the output columns.  Although we are only in PowerShell’s first gear, we have revved from tick-over to 5,000 rpm.

Get-Service | Format-Table Name, DisplayName, CanStop, Status -auto

Now we can focus on one property such as ‘Status’ and then filter for values like ‘Running’ or ‘Stopped’.

Get-Service | Where-Object {$_.Status -eq ‘Running’}


Next Week

Next week I will explain PowerShell’s three most valuable learning techniques.

Guy Recommends: Tools4ever’s UMRAUMRA The User Management Resource Administrator

Tired of writing scripts? The User Management Resource Administrator solution by Tools4ever offers an alternative to time-consuming manual processes.

It features 100% auto provisioning, Helpdesk Delegation, Connectors to more than 130 systems/applications, Workflow Management, Self Service and many other benefits. Click on the link for more information onUMRA.

If you like this page then please share it with your friends


See more Microsoft PowerShell tutorials

PowerShell Tutorials  • Methods  • Cmdlets  • PS Snapin  • Profile.ps1  • Exchange 2007

Command & Expression Mode  • PowerShell pipeline (|)  • PowerShell ‘where‘  • PowerShell ‘Sort’

Windows PowerShell Modules  • Import-Module  • PowerShell Module Directory 

If you see an error of any kind, do let me know.  Please report any factual mistakes, grammatical errors or broken links.