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.
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.
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.
Guy
Recommends: WMI Monitor and It's Free!
Windows Management Instrumentation (WMI) is one of the hidden
treasures of Microsoft 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.
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 Clear-Host Get-Help Get-ChildItem
-full
Note 1: 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 2: 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 3: 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.
# PowerShell script to list the DLL files under the system32 folder
Clear-Host $Dir = Get-Childitem C:\windows\system32 -recurse # $Dir |Get-Member $List = $Dir | where {$_.extension -eq ".dll"} $List |
format-Table name
Learning Points
Note 1: 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 2:
$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 3: $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 4: 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.
Solarwinds' Config Generator is a free tool, which puts you in charge of
controlling changes to network routers and other SNMP devices.
Boost your network performance by activating network device features
you've already paid for.
Guy says that for newbies the biggest benefit of this free tool is that
it will provide the impetus for you to learn more about configuring the SNMP
service with its 'Traps' and 'Communities'.
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:
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.