Windows 7 PowerShell 2.0

PowerShell 2.0 in Windows 7PowerShell for Windows 7

Windows 7 PowerShell 2 sounds like a baseball result, but actually, it’s the latest way of configuring the operating system from the command line.

Topics For Windows 7 PowerShell 2.0


Introduction to PowerShell 2.0

# Cmdlet Example

The benefits of PowerShell v 2.0 in Windows 7 depend on your previous experience, and how curious you are!

The rest of this page is aimed at helping those with little or no experience of PowerShell to experiment with cmdlets such as Get-process.  To newbies with no scripting experience I would also like to plant the seed of an idea, by learning PowerShell you will soon be writing scripts to automate your system, this will not only make you more efficient, but make computer configuration more enjoyable.

One day PowerShell will supersede DOS, however, its real advantage is that you can speed up configuration by typing a few commands, rather than endlessly clicking through GUI menus, for example type this cmdlet, Get-hotfix.  Incidentally, all those old DOS commands work at the PowerShell command-line, therefore you have nothing to lose by abandoning cmd.exe and trying Windows 7’s PowerShell with its ISE (Integrated Scripting Engine = GUI).

So far I have grossly underplayed PowerShell’s vast abilities as a scripting language, this is because I don’t want to discourage people learning PowerShell, just because they have no knowledge of VBScript, UNIX, C++ or any other scripting language.  I want to shout from the roof tops that PowerShell is that rare combination of an easy-to-learn language coupled with more sophisticated scripting power than you will ever need.

PowerShell v 2.0 Brings Remoting

The big improvement in PowerShell v 2.0 is its remoting capability; the significance is twofold, firstly, the Windows 7 desktops can communicate with the server using PowerShell commands.  As a result techies with Windows 7 laptops can configure their servers remotely by running PowerShell scripts.  Secondly, client logon scripts written in PowerShell, which reside on the server, can run on Windows 7 more easily.  Previously you would have had to install PowerShell on each Vista client; moreover PowerShell 1.0 had negligible remoting capability.

Another new feature in PowerShell 2.0 is a GUI.  Look out for the ISE version of PowerShell, along with the GUI you get a built-in script editor, thus its easier to edit scripts and run just snippets of the code more easily. 

Getting Started with PowerShell in Windows 7Microsoft PowerShell in Windows 7

Launching PowerShell in Windows 7 is a trivial task; unlike Vista, the .NET Framework and PowerShell binaries are already installed so just:

  • Click on the Windows 7 Start Orb
  • Type power
  • Select ‘Windows PowerShell ISE’ for the GUI version
  • Select plain ‘Windows PowerShell’ for the command-line version.

Microsoft Windows 7 PowerShell

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

Windows 7 PowerShell Tutorial

Simple Examples

# Window 7 PowerShell Example


Get-Eventlog -list


Get-Command -verb get

Slightly more advanced Windows 7 PowerShell commands

Get-Service | where {$_.Status -eq "Running"}

Note 1:  In PowerShell .status can be "Running", but not "Started".  Thanks to Alexander Nusinovich for reminding me.


Get-EventLog system -newest 2000 | where {$_.entryType -match "Error"}

These short examples are just to whet your appetite, see more Windows 7 PowerShell tutorials

PowerShell Tutorial Windows Files

While experienced PowerShell users won’t admit it, everyone sneaks a look at Get-Help when they research a new cmdlet.  My purpose in introducing Get-Help is to reveal the secret of how I learn about PowerShell.

# PowerShell Basics: Get-Help for Cmdlets
Get-Help Get-ChildItem  -full

Note 2:  Actually, plain ‘Help Verb-Noun’ also works because ‘Get’ is the default verb and PowerShell assumes that what you meant, for instance try: ‘Help Get-ChildItem’.  Talking of assumptions PowerShell assumes that first instruction is for the location, thus you don’t need to explicitly use the -path parameter in most Get-ChildItem scripts.

Note 3:  The point of calling for help is to seek useful -parameters for your project (Some people call them switches).  In this case -recurse, -include and possibly -force are important modifiers for the main Get-ChildItem cmdlet.

Note 4:  I don’t know why you would ever call for Get-Help without appending its -full parameter.  What this does is give you examples of how apply the particular cmdlet.

See more on PowerShell 3.0’s Update-Help »

PowerShell Tutorial – List .dll Files

# PowerShell script to list the DLL files under the system32 folder
$Dir = Get-Childitem C:\windows\system32 -recurse
# $Dir |Get-Member
$List = $Dir | where {$_.extension -eq ".dll"}
$List | Format-Table name

Learning Points

Note 5: Beginning a script with Clear-Host is one of my idiosyncrasies, it simply means clear the screen of any previous output (just as it does in DOS).  The hash symbol # means a remark, or do not process this line.

Note 6:  $Dir = Get-Childitem C:\windows\system32 -recurse
This command sets the variable $Dir to the path of the files that we seek.  You have probably guessed the purpose of the -recurse switch, to drill down to the sub-folders.  Get-childitem is often abbreviated to its alias, gci.

Note 7:  $List = $Dir | where {$_.extension -eq ".dll"}
$List is another variable whose purpose is to filter the output, as a result we get only files with .dll extension.  Pay particular attention to the construction $_. which means, in this pipeline.  Also observe that instead of the equals sign, PowerShell needs -eq.

Note 8:  One of PowerShell’s features is the pipe symbol (|).  Most PowerShell scripts contain at least one pipe to control, or filter the output of the main command.

Note 9  Out-GridView: PowerShell v 2.0 introduces a new cmdlet to control data display.  See more on how to pipe the results into out-GridView.

Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Orion performance monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds’ Network Performance Monitor

PowerShell Registry

As a beginner, people will tell you that accessing the registry with PowerShell is as easy as accessing the file system.  Guy says that doing useful work means learning knack.  Let start with PowerShell’s PSDrive provider, which opens the door to the registry.  Thus you can type:

CD HKLM:\   (Just as easy as when you type:  cd C:\)

See more on editing the PowerShell Registry

Summary of Windows 7 for PowerShell

In Windows 7 PowerShell version 2.0 is integrated into the operating system.  This is an improvement over Vista and Windows Server 2003 where you had to download version 1.0 along with .NET Framework, and then install them manually.

While this scripting language is increasingly used by server administrators, there is no reason why keen amateurs should not try PowerShell, firstly as a replacement for cmd.exe, then onward to using PowerShell cmdlets to interrogate the operating system, for example type, Get-process.  If you do experiment with Windows 7’s PowerShell be sure to seek out the ISE version which has a GUI with an integral script editor.

It looks as though Windows 8 PowerShell will be very similar.

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


Microsoft Windows Version 7 Configuration Topics